TurboSQL Guide

DateTime Formats

Previous  Top  Next


The native format for datetime literals is composed of a date literal and a time literal separated by an underscore '_'. This format can be used with and without quotes:

SELECT * FROM WorkOrder
WHERE StartTime >= 31.1.2001_14:10:00

or

SELECT * FROM WorkOrder
WHERE StartTime >= '31.1.2001_14:10:00'

The other way to specify a datetime is to proceed it by the keyword TIMESTAMP and enclose it in single quotes. Again, we have three different representations here:

The American timestamp format:

SELECT * FROM WorkOrder
WHERE StartTime >= TIMESTAMP'1/31/2001 2:10:00 pm'

The international timestamp format:

SELECT * FROM WorkOrder
WHERE StartTime >= TIMESTAMP'2001-1-31 14:10:00'

The German timestamp format:

SELECT * FROM WorkOrder
WHERE StartTime >= TIMESTAMP'31.1.2001 14:10:00'

When the nature of the string is obvious like in the above samples, you can omit the keyword TIMESTAMP.

Note
The first alternative with the native format without enclosing quotes cannot be used with the Delphi component TTdbQuery. The VCL parser for SQL commands recognizes the colon as the starting character of a parameter and creates an error message.