TurboSQL Guide

Date Formats

Previous  Top  Next

Date values can be indicated either in the TurboDB proprietary format which does not require quotation marks (dd.mm.yyyy) or in three different standard date formats. Where local date formats are allowed, only the TurboDB format and the current local format are valid. In these situations the three standard date formats are not accepted.

The native format is dd.mm.yyyy. This format is a very logical one and can not be mistaken by the parser for arithmetic calculations. For this reason, it is not necessary to enclose such a date literal in quotation marks. Example:

SELECT * FROM orders
WHERE saledate <= 31.12.2001

searches for sales on 31 December 2001. This format is always valid and always interpreted in the same way. You should prefer it wherever you do not want the date format to adjust to the local settings on the computer.

The quoted date formats are valid wherever local date formats are not allowed, for example in all SQL statements. There is an American, an International and a European date format. The quoted string is preceded by the keyword DATE:

SELECT * FROM orders
WHERE saledate <= DATE'12/31/2001'

or

SELECT * FROM orders
WHERE saledate <= DATE'2001-12-31'

or

SELECT * FROM orders
WHERE saledate <= DATE'31.12.2001'

Leading zeros for the month and day fields are optional. If the century is not specified for the year, TurboDB assumes the 20th century for years from 50 to 99 and the 21th century for years from 00 to 49.

You can omit the keyword DATE where the type of the string is obvious like in the above examples.

Example

SELECT * FROM orders
WHERE (saledate > 1.1.89) AND (saledate <= 31.12.20)

searches for sales between the January 1st 1989 and the December 31 2020.