TurboSQL Guide

Time Formats

Previous  Top  Next

Time values can be indicated either in the TurboDB proprietary format which does not require quotation marks (hh:mm:ss) or in two different standard time formats. Where local date formats are allowed, only the TurboDB format and the current local format are valid. In these situations the quoted standard time formats are not accepted.

The native format expects time literals to be in the format HH:mm:ss.ttt; where HH are the hours and mm the minutes. TurboSQL uses the 24 hour scale, that is 2:10 is in the early morning (2:10 AM) while 14:10 is in the early afternoon (2:10 PM). This time literal must not be enclosed in quotation marks.

(ID, StartTime) VALUES ('B00120', 22:30)

This format is always valid and always interpreted in the same way. You should prefer it wherever you do not want the time format to adjust to the local settings on the computer.

If you prefer, you can enter the time value in the American format hh:mm:ss am/pm. In order to do this, you must enclose the time literal in single quotes and proceed it by the keyword TIME:

(ID, StartTime) VALUES ('B00120', TIME'10:30:00 pm')

Where the type of the string is obvious like in the above example, you can omit the keyword TIME. An example where you can not omit it is this one:

SELECT StartTime - TIME'12:00:00 pm' FROM WorkOrder

When you want to use the native format without enclosing quotes with the Delphi/C++ Builder component TTdbQuery, it will create a parameter because the VCL parser for SQL commands recognizes the colon as the starting character of a parameter. You can either delete it or ignore it, the statement will be executed correctly anyway.