This function returns a dual value with:
- A day name as defined in the environment variable DayNames.
- An integer between 0-6 corresponding to the nominal day of the week (0-6).
Return data type: dual
|date||The date to evaluate.|
If you do not specify first_week_day, the value of variable FirstWeekDay will be used as the first day of the week.
If you want to use another day as the first day of the week, set first_week_day to:
The integer returned by the function will now use the first day of the week that you set with first_week_day as base (0).
Unless stated otherwise FirstWeekDay is set to 0 in these examples.
weekday( '1971-10-12' )
returns 'Tue' and 1
|weekday( '1971-10-12' , 6)||
returns 'Tue' and 2.
In this example we use Sunday (6) as the first day of the week.
SET FirstWeekDay = 6;
|returns 'Tue' and 2.|
weekday can be used in a load script to return a string and a number representing a day of the week, even if FirstWeekDay and ReferenceDay are already set in the script. The load script below includes specific FirstWeekDay and ReferenceDay values and then uses weekday to return both strings and numbers that represent days of the week from the data in the transaction_date column.
In the results shown, the Day column contains the strings returned, while Numeric value of Day and Numeric value of week starting from Sunday contain the numeric values returned. In the load script weekday is multiplied by 1 as a simple way to make sure that the data type returned is numeric.
In the Data load editor, create a new section, and then add the example script and run it. Then add, at least, the fields listed in the results column to a sheet in your app to see the result.
|transaction_id||transaction_date||Day||Numeric value of Day||Numeric value for a week starting from Sunday|