Koyix
Koyix

Reputation: 181

Proper DateTime Format on Oracle

I have problem with read a datetime format like this : 7/1/2014 6:02:09 AM , my goal is I want to compare some date in query oracle by to_date function but it seems different with the format, like there are no zero in the month, day, and hours.

my thought for the better query is like this to_date('7/1/2014 6:02:09 AM','MM/DD/YYYY HH:MI:SS AM')

but seems like I have wrong format for this.

Thanks in advance

Upvotes: 0

Views: 407

Answers (2)

Koyix
Koyix

Reputation: 181

Finally I found the format, I have to change first the AM PM format to 24 hours timestamp :

TO_CHAR(TO_DATE('01/01/1970 00:00:00', 'MM/DD/YYYY HH24:MI:SS')

thank you all audiences :)

Upvotes: 0

Ненад
Ненад

Reputation: 341

Try this format instead:

to_date('07-01-2014 12:15','MM-DD-YYYY HH:MI'))

Upvotes: 1

Related Questions