|
Character and Binary strings | Lexical Elements of the SQL Language | Comments |
You can enter the values of DATE, TIME and TIMESTAMP types in SQL using three different ways: the SQL standard, ODBC standard and 602SQL standard. The following table describes the individual methods:
Date | Time | Date and time | |
SQL standard | |||
ODBC standard | |||
602SQL standard |
If the time value contains the time zone specification (UTC notation), it is entered as follows:
Time with a time zone | Date with time and time zone | |
SQL norm | ||
ODBC specification | ||
602SQL style |
Notes:
Notation according to the ODBC standard in braces is not considered a comment. If you specify a decimal fraction of a second, it is ignored.
The time zone designation must immediately follow after the time notation and begin with a + or - sign.
Variances from the SQL Standard
Example:
Inserting date, time and timestamp values using the different methods:
procedure InsDate(); BEGIN INSERT INTO DateTime(date,time,datetime) VALUES (DATE'1998-02-27',TIME'12:34:56',TIMESTAMP'1998-02-27 12:34:56'); INSERT INTO DateTime(date,time,datetime) VALUES ({d'1998-02-27'},{t'12:34:56.789'},{ts'1998-02-27 12:34:56.789'}); INSERT INTO DateTime(date,time,datetime) VALUES (27.2.1998,12:34:56,27.2.1998 12:34:56); END
Character and Binary strings | Lexical Elements of the SQL Language | Comments |