Extract part of a date number.
Syntax: @datepart(d, fmt)
d: date number, series, vector
fmt: date format string
Return: number, series, vector
Returns a number representing part of a date, using a date number corresponding to the date and a fmt, where fmt is a component of a date format string.
Examples
Consider the d date number value 730110.5 (noon, December 23, 1999).
The values for
@datepart(730110.5, "dd")
@datepart(730110.5, "w")
@datepart(730110.5, "ww")
@datepart(730110.5, "mm")
@datepart(730110.5, "yy")
are 23 (day of the month), 1 (day of the week), 52 (week in the year), 12 (month in the year), and 99 (year), respectively).
If DSER is a series containing date numbers,
series dser1 = @datepart(dser, "mm")
gives the month of the year given by each observation in DSER in the workfile sample. You may use “@date” in place of DSER to obtain results using the built-in dates in the workfile structure.
If AVEC is a vector containing date numbers,
vector avec1 = @datenext(avec, "y")
returns the year for each element of the vector.
Cross-references
See
“Dates” and
“Date Formats”for additional details on date numbers and date format strings.