Reputation: 6919
I am trying to get data from a table where start_date is less than or equal to a particular date and time value:
SELECT * FROM Table1 WHERE START_DATE <= TO_DATE('2/21/2018 2:40:20 PM', 'MM/dd/yyyy hh:mm:ss tt')
The error I am getting is format code appears twice
I have tried different formats but still cannot get it right
Upvotes: 0
Views: 49
Reputation: 17944
You have two problems.
1) The format model for minutes is "mi", not "mm".
2) The format model for AM/PM is "AM", not "tt".
So,
TO_DATE('2/21/2018 2:40:20 PM', 'MM/dd/yyyy hh:mi:ss AM')
Or, easier,
TO_DATE('2/21/2018 14:40:20', 'MM/dd/yyyy hh24:mi:ss')
(i.e., a 24-hour clock)
Upvotes: 3