Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What date format does Oracle/Toad expect?

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?

like image 324
B. Clay Shannon-B. Crow Raven Avatar asked Apr 18 '12 19:04

B. Clay Shannon-B. Crow Raven


People also ask

What is the date format in Toad?

alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'; alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS'; alter session set nls_timestamp_tz_format = 'YYYY-MM-DD HH24:MI:SS'; select sysdate from dual; select systimestamp from dual; Session altered. Session altered.

What is the format for date in Oracle?

Oracle stores dates in an internal numeric format representing the century, year, month, day, hours, minutes, seconds. The default date format is DD-MON-YY. SYSDATE is a function returning date and time.

What should be the format of date in SQL?

SQL Date Data Types DATE - format YYYY-MM-DD. DATETIME - format: YYYY-MM-DD HH:MI:SS. TIMESTAMP - format: YYYY-MM-DD HH:MI:SS.

How do I display a date in YYYY-MM-DD format in Oracle?

Use TO_CHAR to display it in any format you like. For example: SELECT TO_CHAR ( TO_DATE (date_value, 'yyyy-mm-dd') , 'mm/dd/yyyy' ) FROM table_x; Things are much easier if you store dates in DATE columns.


1 Answers

Safest to use TO_DATE:

AND AVAILABLEDATE = TO_DATE('09/Apr/2012', 'DD/Mon/YYYY')
like image 60
cagcowboy Avatar answered Oct 03 '22 16:10

cagcowboy