Skip to content

DateGetYearOfWeekISO

See Also: Time and Date Functions

Purpose

This function returns the year of the week that the given DateTime value's week number falls into.

When DateGetYearOfWeekISO is called, it uses the ISO 8601 standard (ISO Week Date). This specifies that a date’s week of the year may be in the last week of the previous year or the first week of the next year. Therefore, in addition to the week of the year, you may also need to know which year this week is actually part of. By comparing the year returned to the year portion passed in dtVar (using DateGetYear), you can determine if a date has been placed in the last week of the previous year or the first week of the next year.

DateGetYearOfWeekISO would most likely be called from DateGetWeekOfYearISO, which is an alternate version of DateGetWeekOfYear that returns the day of the week of the given DateTime variable, using a counting mechanism where the first week of the year is defined as the first week that contains four days (i.e., the week that contains the first Thursday in the new year), and the start of the week is Monday.

Return Type

Integer

Syntax

Use GlobalDateTimeFunctions.pkg
DateGetYearOfWeekISO({dtVar})

Parameters

Example

This sample gets the week of the year (based on the starting day of the week being 1=Monday).

Procedure Test
    DateTime dtVar
    // Get the current local date and time
    Move (CurrentDateTime()) to dtVar
    Showln "The year of the week is: " (DateGetYearOfWeekISO(dtVar))
End_Procedure