# ParseDate

Release: 4.6  •  5.0  •  5.1  •  5.2  •  5.3  •  5.4  •  6.0  •  6.1  •  6.2  •  6.3

Parses a textual date «date» into a date time value, with a numeric value equal to the number of days elapsed since Analytica's date origin. When the "Use Excel date origin" preference is not set, the origin is 1 Jan 1904, and when set it is 1 Jan 1900.

An optional second parameter, «badVal», specifies the value returned when «date» does not parse as a date-time, or is not text. The default when this parameter is omitted is to return Null. A useful usage is to repeat the first parameter as the second parameter, as in ParseDate(x, x), which then parses the date cells and leaves all other cells with the values already there.

A date like "09/10/11" would usually be interpreted as 10-Sep-2011 in the United States, as 9-Nov-2011 in many European and South American countries, and as 11-Oct-2009 in several east Asian countries. ParseDate uses your computer's regional settings to determine the ordering of date components when parsing. You can override this by specifying the optional «dateTemplate» parameter, which should contain the characters 'd', 'M' and 'y' in the desired order. In other words, it should be 'dMy', 'Mdy' or 'yMd', or for you prefer for style reasons you can include dashes or include multiple characters, e.g., 'd/MM/yyyy', 'M/d/y', 'yyyy/M/d', etc.

## Examples

ParseDate("1 Aug 2007") → 1-Aug-2007
ParseDate("8/1/2007") → 1-Aug-2007
ParseDate("1 Aug 2007") * 1 → 37833

The second example assumes English-language regional settings. The third example assumes that the "Use Excel date origin" preference is off, and exposes the underlying numeric value by using multiplication to force a conversion of the date-time value to a number.

ParseDate("8/1/2007", dateTemplate:"dMy") → 8-Jan-2007
 Local data := ["Sky plant", "12/25/2016", 1.34M] Do ParseDate(data, data) → ["Sky plant", 25-Dec-2016, 1.34M]

## Notes

ParseDate is useful when parsing data read in from textual files.

There are other ways of entering and parsing dates. You can enter dates directly into definitions or edit table cells when the variable's number format is set to Date. This is generally how dates are entered in models, rather than through the use of ParseDate.