Command Reference : String and Date Function Reference
  
 
@dateval
Convert the string representation of a date into a date number.
Syntax: @dateval(str[, fmt])
str: string
fmt: (optional) date format string
Return: date number
Returns the date number associated with the string representation of a date, str. Interpretation of the string may be controlled of using the optional format string fmt.
Examples
@dateval("12/1/1999", "mm/dd/yyyy")
contains the date number (730088) for December 1, 1999. The format indicates that the string represents a one or two-digit month identifier, a “/” separator, a one or two-digit day identifier, a “/” separator, and a 4-digit year identifier.
@dateval("12/1/1999", "dd/mm/yyyy")
contains the date number (729765) for January 12, 1999. The format reverses the month and day identifiers used above.
If ALPHA1 is an alpha series, the command
series ser1 = @dateval(alpha1, "yyyy-MM-DD HH:mi:ss")
fills DSER with date numbers associated with the ISO 8601 representation of the string dates for each observation in the workfile sample. Here, we have used the capitalized forms of “MM”, “DD”, and “HH” to ensure that we interpret the required leading zeros.
If AVEC1 is an svector, the commands
svector vec1 = @dateval(avec1, "yyyy-Month-dd")
fills DVEC with the date numbers associated with the strings in AVEC1, interpreted as a four-digit year, followed by the full name of the month (with first letter capitalized), and the one or two-digit day identifier, all separated by dashes.
Cross-references
See “Dates” and “Date Formats”for additional details on date numbers and date format strings.
See @strdate for converting date numbers to date strings, and @strdate for obtaining strings for workfile dates.