Most portable SQL date string format

In all the different dialects of SQL, which string representation for Date and / or DateTime will most likely be interpreted correctly? Is there an SQL standard? Are the two answers the same or similar?

EDIT:

For suggestions, can we comment on any known SQL dialects that do not match?

+4
source share
3 answers

I would argue that the ISO 8601 time standard is likely to be one of them.

'YYYY-MM-DDThh: mm: ssTZD'

Or there may be a slight change:

'YYYY-MM-DD hh: mm: ss'

http://www.w3.org/TR/NOTE-datetime

+7
source

If you want to be portable across databases, perhaps you should consider abstracting everything using something like ADO or OTL. Almost all databases support ODBC connections, and you can simply use something like an OTL datetime container to write and read dates.

+2
source

There's also DATE'2014-07-02' , which is accepted by Oracle, DB2, MySQL and Teradata, but not MS SQL or PostgreSQL.

0
source

All Articles