SQL — Time and Date Constants


It is possible to represent time and date values as constants. Date constants may be represented as strings in the YYYY-MM-DD format:

Select DAYOFWEEK('1963-09-30') from customer

Date constants can be represented as a standard ODBC date clause. For example:

{d'1996-09-30'}

Date constants must be complete and must contain valid year, month, and day information in the correct positions within the string.

Time constants follow the hh:mm:ss:ffffff format and are more relaxed than date constants. For example, a complete date constant does not need to be supplied for the time functions to understand them:

Select emp_name from timeclock where HOUR(checkin) = hour('04:11')