Skip to content

DateGetWeekOfYear_WDS

See Also: Time and Date Functions

Purpose

DateGetWeekOfYear_WDS (WDS = week day start) is a lower-level version of DateGetWeekOfYear that returns the week of the year for the passed DateTime value and starting week day.

This function uses a counting mechanism where the week that contains January 1 is always considered the first week of the year.

You should rarely need to use this function, as DateGetWeekOfYear (which starts on Sunday) and DateGetWeekOfYearISO (which starts on Monday and has a more complex set of rules) are the two main methods used for counting the week of the year.

Note that passing 1 as iWeekDayStart makes this behave the same as DateGetWeekOfYear, and passing 2 as iWeekDayStart makes this behave the same as DateGetOfWeekISO. Since these are the two main standards, you should rarely need to use this function.

Return Type

Integer

Syntax

Use GlobalDateTimeFunctions.pkg
DateGetWeekOfYear_WDS( {dtVar}, {iWeekDayStart} )

Where:

  • {dtVar} is a value of type DateTime.
  • {iWeekDayStart} may be a value from 1 to 7, where:
  • 1 = Sunday
  • 2 = Monday
  • 3 = Tuesday
  • 4 = Wednesday
  • 5 = Thursday
  • 6 = Friday
  • 7 = Saturday

Example

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

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