week
This function calculates the week number from the date. -1 is returned if the input parameter contains no recognizable date.
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.
Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter
1-2
No. | Type | Description |
---|---|---|
1 input |
date or string converted to date set |
Date Value to extract as described above. Vectorization: Put multiple values into a (nested) set. |
Opt. 2 input |
numeral | Option 0: ISO week number, 1..52 or 53, all weeks are 7 days long. In some years, week 1 begins in the last days in December. In some other years, week 53 may run into early January. |
Type | Description |
---|---|
numeral set |
week 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. |
d[1] = { 31.12.2020, 31.12.2021, 31.12.2022 }; // still a string. week() converts to date
d[2] = { 01.01.2020, 01.01.2021, 01.01.2022 };
for (option[] = 0, option[] <= 4, option[]++)
{
print( week( d[1]{0}, option[] ), " ", week( d[1]{1}, option[] ), " ", week( d[1]{2}, option[] ), " " );
echo ( week( d[2]{0}, option[] ), " ", week( d[2]{1}, option[] ), " ", week( d[2]{2}, option[] ) );
}
53 52 52 1 53 52
53 52 52 1 0 0
20.53 21.52 22.52 20.01 21 22
2020.53 2021.52 2022.52 2020.01 2021 2022
-1 -1 -1 -1 -1 -1