Formatting Dates for Input
From InterBase
Go Up to Working with Dates and Times
Dates for input as data type DATE can have any of the following forms:
- YYYYpMMpDD
- MMpDDpYYYY
- DDpMMpYYYY
- YYpMMpDD
- MMpDDpYY
- DDpMMpYY
where:
- DD = one- or two-digit day
- MM = one- or two-digit month, or a three-letter month abbreviation, or the full English month name (case does not matter)
- YY = last two digits of a year
- YYYY = four-digit year
- p = any ASCII punctuation character; extra whitespace (tabs or spaces) is ignored
These restrictions apply:
- In Year-Month-Day forms, the year must always be four digits.
- In Month-Day-Year forms, the year can be either two digits or four digits. If you enter a date with only two digits for the year, InterBase uses its “sliding window” algorithm to assign a century to the year. See the string_to_datetime() routine description below for more information.
- If you use an all-numeric form in which the year comes last, and you use a period as a separator, InterBase assumes the form is Day-Month-Year. For example, ‘12.04.2002’ is interpreted to mean “April 12, 2002,” but ‘12-04-02’ means December 4, 2002.”
From the InterBase engine string_to_datetime() routine:
* String must be formed using ASCII characters only. * Conversion routine can handle the following input formats * “now” current date and time * “today” Today’s date 0:0:0.0 time * “tomorrow” Tomorrow’s date 0:0:0.0 time * “Yesterday” Yesterday’s date 0:0:0.0 time * YYYY-MM-DD [HH:[Min:[SS.[Thou]]]]] * MM:DD[:YY [HH:[Min:[SS.[Thou]]]]] * DD:MM[:YY [HH:[Min:[SS.[Thou]]]]] * Where: * DD = 1 .. 31 (Day of month) * YY = 00 .. 99 2-digit years are converted to the nearest year * in a 50-year range. Eg: if this is 1996: * 96 ==> 1996 * 97 ==> 1997 * ... * 00 ==> 2000 * 01 ==> 2001 * ... * 44 ==> 2044 * 45 ==> 2045 * 46 ==> 1946 * 47 ==> 1947 * ... * 95 ==> 1995 * If the current year is 1997, then 46 is converted * to 2046 (etc.) * = 100.. 5200 * MM = 1 .. 12 (Month of year) * = “JANUARY”...(etc.) * HH = 0...23 (Hour of day) * Min = 0...59 (Minute of hour) * SS = 0...59 (Second of minute - LEAP second not supported) * Thou = 0...9999 (Fraction of second) * HH, Min, SS, Thou default to 0 if missing. * YY defaults to current year if missing. * Note: ANY punctuation can be used instead of : (eg: / - etc) * Using . (period) in either of the first two separation * points will cause the date to be parsed in European DMY * format. * Arbitrary whitespace (space or TAB) can occur between * components.