This page is part of the book SQL-99 Complete, Really, by Peter Gulutzan & Trudy Pelzer. The authors have graciously allowed us to reproduce the contents of the book here. Because the book is about the SQL-99 standard, the contents of this and other pages in the book may not directly apply to MariaDB. Use the navigation bar to navigate the book.

The "typical" SQL DBMS supports date, time and timestamp data types but interval (as a separate data type) is not common yet. The majority of SQL DBMSs can't handle time zones, can't handle fractional seconds and can't handle leap seconds. For example, the Oracle DATE data type is typically a timestamp (i.e.: it includes both a date portion and a time portion, despite the name) with no fractional seconds, formatted as DD-MON-YY (e.g.: 06-JAN-97). Valid dates fall into the range January 1 4712 B.C. to December 31 4712 A.D. Intervals are expressed only as integers, representing number of days. The Oracle SYSDATE function returns the current date and the current time.

ODBC has several datetime functions; most are replaceable with standard SQL. Here are the different names to expect.

StandardODBC
CURRENT_DATECURDATE
CURRENT_TIMECURTIME
CURRENT_TIMESTAMPNOW
EXTRACT(MONTH ...MONTH
(EXTRACT(MONTH...)/4QUARTER
EXTRACT(DAY ...DAYOFMONTH
not supportedDAYOFWEEK
not supportedDAYOFYEAR
EXTRACT(HOUR ...HOUR
EXTRACT(MINUTE ...MINUTE
EXTRACT(SECOND ...SECOND

Comments

Comments loading...