weekday

Prev Next

Function Names

weekday

Description

Retrieves the weekday number from the date. If you need the weekday name, the use following function instead:
str( date[], "Tttt" );, possible with a 3rd parameter specifying the language.

Vectorization: This function supports vectorization in the 1st function parameter. Instead of providing a single value, you can provide a set or even a nested set which contain multiple values. The function will then process every value and its return value contains a corresponding set containing all results.

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

1-2

Parameters

No.TypeDescription
1
input
date or string converted to date
set
Date

Value to extract as described above. Vectorization: Put multiple values into a (nested) set.

1
input
numeral Weekday calculation variant

1: 1 = Sunday, 2 = Monday .. 7 = Saturday
2: 1 = Monday, 2 = Tuesday .. 7 = Sunday
3: 0 = Monday, 1 = Tuesday .. 6 = Sunday
All other values are treated as 2.

Default value: 2

Return value

TypeDescription
numeral
set
Weekday number

Returned value as described above. -1 returned if no appropriate date found. If vectorization is applied, then the function returns a set containing mulitple values.

Examples

               for all( { date(today) .. date(today)+10, date("15:00:00") }, date[] )
               {
                       echo( str( date[], "Ttt, DD.Mmm.YYYY: " ), weekday(date[], 1), " ",
                                 weekday(date[], 2), " ", weekday(date[], 3) );
               }

Output

Sat, 19.Oct.2024: 7 6 5
Sun, 20.Oct.2024: 1 7 6
Mon, 21.Oct.2024: 2 1 0
Tue, 22.Oct.2024: 3 2 1
Wed, 23.Oct.2024: 4 3 2
Thu, 24.Oct.2024: 5 4 3
Fri, 25.Oct.2024: 6 5 4
Sat, 26.Oct.2024: 7 6 5
Sun, 27.Oct.2024: 1 7 6
Mon, 28.Oct.2024: 2 1 0
Tue, 29.Oct.2024: 3 2 1
___, __.___.____: -1 -1 -1
Try it yourself: Open LIB_Function_weekday.b4p in B4P_Examples.zip. Decompress before use.