Converts a string whose value is a valid date to a value of datatype date.
Date ( string )
Argument |
Description |
---|---|
string |
A string containing a valid date (such as Jan 1, 2004, or 12-31-99) that you want returned as a date |
Date. Returns the date in string as a date. If string does not contain a valid date, Date returns null.
The value of the string must be a valid date.
Valid dates can include any combination of day (1–31), month (1–12 or the name or abbreviation of a month), and year (two or four digits). Leading zeros are optional for month and day. If the month is a name or an abbreviation, it can come before or after the day; if it is a number, it must be in the month location specified in the Windows control panel. A 4-digit number is assumed to be a year.
If the year is two digits, the assumption of century follows this rule: for years between 00 and 49, the first two digits are assumed to be 20; for years between 50 and 99, the first two digits are assumed to be 19. If your data includes dates before 1950, such as birth dates, always specify a four-digit year to ensure the correct interpretation.
The function handles years from 1000 to 3000 inclusive.
An expression has a more limited set of datatypes than the functions that can be part of the expression. Although the Date function returns a date value, the whole expression is promoted to a DateTime value. Therefore, if your expression consists of a single Date function, it will appear that Date returns the wrong datatype. To display the date without the time, choose an appropriate display format. (See “Using DataWindow expression functions”.)
These expressions all return the date datatype for July 4, 2004 when the default location of the month in Regional Settings is center:
Date("2004/07/04") Date("2004 July 4") Date("July 4, 2004")