UnpackDateTime (open)

Returns a record from an unpacked timestamp

Syntax

LOADLIB "wh::datetime.whlib";

RECORD FUNCTION UnpackDateTime(DATETIME date)

Parameters

DATETIME date

The DateTime value to unpack

Return value

RECORD

A record with the unpacked date and time. If an invalid date was used, the function returns a non-existing record.

INTEGER dayofmonth

Representing the day of the month at timestamp @italic date. 1 = the first day, 2 = the second day etc.

INTEGER dayofweek

Representing the day of the week at timestamp @italic date. 1 = monday, 2 = tuesday etc.

INTEGER dayofyear

Representing the day of the year at timestamp @italic date. 1 = Januari 1st, 2 = Januari 2nd, 32 = Februari 1st etc.

INTEGER hour

Representing the hour of the day at timestamp @italic date. Ranges from 0 to 23

INTEGER minute

Representing the minute of the hour at timestamp @italic date. Ranges from 0 to 59

INTEGER month

Representing the month part of timestamp @italic date. 1 = Januari, 2 = Februari etc.

INTEGER msecond

Representing the millisecond of the second at timestamp @italic date. Ranges from 0 to 999

INTEGER second

Representing the second of the minute at timestamp @italic date. Ranges from 0 to 59

INTEGER week

Representing the week part of timestamp @italic date. 1 = the first week, 2 = the second week etc. According to ISO-8601, week 1 of a given year is the week that includes the first thursday of that year.

INTEGER year

Representing the year part of timestamp @italic date.

INTEGER yearofweek

Representing the year in which the week in which this timestamp @italic date is situated. According to ISO-8601, week 1 of a given year is the week that includes the first thursday of that year, so the week can be in a different year than the date itself actually is.

Description

UnpackDateTime takes a DateTime value and returns a record containing the unpacked parts of the DateTime value

Examples

// Unpack the current DateTime
RECORD currentDateTime := UnpackDateTime(GetCurrentDateTime());

// Get the current hour
INTEGER theHour := currentDateTime.hour

// Get the current day of the week
INTEGER theWeekDay := currentDateTime.dayofweek