0

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

3
  • to_date('7/1/2014 6:02:09 AM','MM/DD/YYYY HH:MI:SS AM') returns a valid DATE value, so where is your problem? Commented Oct 30, 2014 at 7:56
  • I'm asking the format date above because my MM/DD/YYYY HH:MI:SS AM was false Commented Oct 30, 2014 at 8:38
  • Do you want to convert a DATE into a string and convert this with another string? Do the opposite, convert the string into a DATE and compare then the date values - this will work. Commented Oct 30, 2014 at 8:41

2 Answers 2

1

Try this format instead:

to_date('07-01-2014 12:15','MM-DD-YYYY HH:MI'))
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for edit @Krumia I'm from mobile phone and posting codes isn't simple :)
0

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 :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.