I need to convert a string into a Date in oracle.
The format of the string is like this:
'08/11/1999 05:45:00 p.m.'
But the last position can change pm or am I tried to do some like:
to_date('08/11/1999 05:45:00 p.m.', 'dd/mm/yyyy hh:mi:ss a.m./p.m.')
to_date('08/11/1999 05:45:00 p.m.', 'dd/mm/yyyy hh:mi:ss am/pm')
But return me an error ORA-01855: AM/AM or PM/PM required... any idea?
Try this:
to_date
( '08/11/1999 05:45:00 p.m.'
, 'dd/mm/yyyy hh:mi:ss a.m.'
, 'nls_date_language=american'
)
It seems that "am" and "pm" rather than "am" and "pm" require nls_date_language
to be set to "american".
to convert time for am
and pm
, just give am
like below
to_date(UPPER('08/11/1999 05:45:00 p.m.'),'dd/mm/yyyy hh:mi:ss a.m.')
hope this might help. please refer https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions183.htm
I tried this case. Here is the right answer: TO_DATE('3/9/2022 9:35:00 PM', 'MM/DD/YYYY hh:mi:ss am', 'nls_date_language=american')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.