How to: |
The week number returned by HNAME and HPART can actually be in the year preceding or following the input date.
The HYYWD function returns both the year and the week number from a given date-time value.
The output is edited to conform to the ISO standard format for dates with week numbers, yyyy-Www-d.
HYYWD(dtvalue, output)
where:
Date-time
Is the date-time value to be edited.
Alphanumeric
The output format must be at least 10 characters long. The output is in the following format:
yyyy-Www-d
where:
Is the four-digit year.
Is the two-digit week number (01 to 53).
Is the single-digit day of the week (1 to 7). The d value is relative to the current WEEKFIRST setting. If WEEKFIRST is 2 or ISO2 (Monday), then Monday is represented in the output as 1, Tuesday as 2.
Using the EDIT function, you can extract the individual subfields from this output.
The following converts the TRANSDATE date-time value to the ISO standard format for dates with week numbers. WEEKFIRST is set to ISO2, which produces ISO standard week numbering:
ISODATE/A10 = HYYWD(TRANSDATE, 'A10');
For date component 1999/01/30 04:16, the value is 1999-W04-6.
For date component 1999/12/15, the value is 1999-W50-3.
iWay Software |