Skip to content

DateGetWeekOfYear

See Also: Time and Date Functions

Purpose

This function returns the week of the year for the given DateTime value. It uses a counting mechanism where the week that contains January 1 is considered the first week of the year, and the start of the week is Sunday. This is commonly used in the US.

DateGetWeekOfYear uses the week that contains January 1 as the first week of the year, while DateGetWeekOfYearISO adheres to the ISO 8601 date and time standard. Additionally, DateGetWeekOfYear_WDS allows you to specify the starting day of the week.

Return Type

Integer

Syntax

Use GlobalDateTimeFunctions.pkg
DateGetWeekOfYear({dtVar})

Where:

Example

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

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