Search

Top 60 Oracle Blogs

Recent comments

A tip for lazy Oracle users – type less with ANSI DATE and TIMESTAMP SQL syntax

I am lazy, therefore if I can type less, I will type less.
Often people are surprised to see that Oracle supports the ANSI DATE and TIMESTAMP syntax in the SQL code, which allows me to shorten the lengthy TO_DATE( …. , ‘YYYY-MM-DD HH24:MI:SS’) syntax a bit. You can just type this if you want to compare some field to a date (day precision):
SQL> SELECT COUNT(*) FROM dba_objects WHERE created > DATE'2012-12-01'; COUNT(*) ---------- 0 SQL> SELECT COUNT(*) FROM dba_objects WHERE created > DATE'2012-01-01'; COUNT(*) ---------- 804 This way you can always use the standard date format regardless of any NLS settings that may say otherwise.