Uniform SQL Date in Oracle SQL and SQL Server Uniform SQL Date in Oracle SQL and SQL Server oracle oracle

Uniform SQL Date in Oracle SQL and SQL Server


I am not sure if SQL Server supports ANSI DATE literal, but it is supported in Oracle. The default string literal format is YYYY-MM-DD.

DATE '2015-09-12'

so, if ANSI standard is supported in SQL Server too, then use it. It is simple.

Based on this link, I think you could use the above in both the databases.

WHERE OrderDate='12-09-2015'

Never do that. You are comparing a DATE with a STRING, you might be just lucky to get correct data depending on your locale-specific NLS settings. But, never rely on implicit data type conversion.


Use this for something which works on both:

CAST('2015-09-14' as date)

The cast is executed only once so has no effect on performance.