HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

Should date formats be specified in SQL statements?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sqlstatementsdateformatsshouldspecified

Problem

I see code from developers using implicit date conversion. I would like a definitive answer to why they should not do this.

SELECT * from dba_objects WHERE Created >= '06-MAR-2012';

Solution

Because '2012/12/1' in the US is 11 months after the same string date in Europe.

Allowing implicit conversions means you are at the mercy of location settings.

If you can name a business where 11 months is an acceptable margin of error I'll be impressed.

Context

StackExchange Database Administrators Q#14511, answer score: 15

Revisions (0)

No revisions yet.