What date format does Oracle/Toad expect?

B. Clay Shannon picture B. Clay Shannon · Apr 18, 2012 · Viewed 41.1k times · Source

In the Toad editor, I've got this SQL:

SELECT INTERLOPERABCID,AVAILABLEDATE,
AVAILABLEQHR,CARPHONEID,
TRUNC((AVAILABLEQHR-1)/12) "COL",
MOD(AVAILABLEQHR-1,12) "ROW"
FROM ABC.INTERLOPERAVAILABILITY
WHERE INTERLOPERABCID>42
AND AVAILABLEDATE='09/Apr/2012'

...but it returns no rows, even though I see many records in the table whose AVAILABLEDATE value = '4/9/2012'

The date format ('09/Apr/2012'; I also tried '04/Sep/2012') looks odd, but at least I get no compilation/execution error with it. When I tried "4/9/2012" and "04/09/2012" it said "ORA-01853: not a valid month"

How must I enter the date to tell it I want to see dates of April 9th, 2012?

Answer

cagcowboy picture cagcowboy · Apr 18, 2012

Safest to use TO_DATE:

AND AVAILABLEDATE = TO_DATE('09/Apr/2012', 'DD/Mon/YYYY')