RobinHood
RobinHood

Reputation: 2397

Setting Date Format in Database

I am working in Oracle 10g XE. I am having Two databases inside by Oracle SQL Developer. I am executing this Query..

SELECT SCHEDULE_ID, START_DATE, END_DATE 
  FROM SCHEDULE
 WHERE C_ID IN (5781) 
   AND START_DATE >=TO_DATE ('1/29/2012','MM/DD/YYYY') 
   AND END_DATE <=TO_DATE ('4/14/2012','MM/DD/YYYY')

In First Database, the data returned correctly. I am executing the same Query in the Second Database, but it does not returns any values. But the data is available in table.

I had executed the query

SELECT dump(START_DATE), dump(END_DATE) FROM SCHEDULE WHERE C_ID=5026 

I am getting the result as,

DUMP(START_DATE ) -> Typ=12 Len=7: 100,112,2,7,1,1,1 
DUMP(END_DATE) -> Typ=12 Len=7: 100,112,2,13,1,1,1

and an important thing is, i should not modify the query..Because its working in all the other databases...

Upvotes: 0

Views: 215

Answers (1)

Rob van Laarhoven
Rob van Laarhoven

Reputation: 8915

Your statement:

SELECT dump(START_DATE), dump(END_DATE) FROM SCHEDULE WHERE C_ID=5026

I am getting the result as,

DUMP(START_DATE ) -> Typ=12 Len=7: 100,112,2,7,1,1,1 and DUMP(END_DATE) -> Typ=12 Len=7: 100,112,2,13,1,1,1

My Comment:

100,112,2,7,1,1,1

100,112,2,13,1,1,1

This results in YYYY-MM-DD

Startdate    0012-02-07 00:00:00
Enddate      0012-02-13 00:00:00

So you're about 2000 years off.

The format of the date datatype is

byte 1 - century (excess 100)  100 - 100 = 00
byte 2 - year (excess 100)  112 - 100 = 12
byte 3 - month = 2
byte 4 - day = 7
byte 5 - hour (excess 1) 1 - 1 = 0
byte 6 - minute (excess 1) 1 - 1 = 0
byte 7 - seconds (excess 1) 1 - 1 = 0

Upvotes: 4

Related Questions