Oracle截止日期为下午/上午 [英] Oracle to_date with p.m./a.m

查看:326
本文介绍了Oracle截止日期为下午/上午的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在oracle中将字符串转换为Date.

I need to convert a string into a Date in oracle.

字符串的格式如下:

'08/11/1999 05:45:00 p.m.'

但是最后一个位置可以更改p.m或a.m. 我尝试做类似的事情:

But the last position can change p.m or a.m. 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')

但是给我返回错误ORA-01855:AM/A.M.或PM/PM需要...有什么想法吗?

But return me an error ORA-01855 : AM/A.M. or PM/P.M. required... any idea ?

推荐答案

尝试一下:

to_date
  ( '08/11/1999 05:45:00 p.m.'
  , 'dd/mm/yyyy hh:mi:ss a.m.'
  , 'nls_date_language=american'
  )

似乎是上午"和下午"而不是"am"和"pm"要求将nls_date_language设置为美国".

It seems that "a.m." and "p.m." rather than "am" and "pm" require nls_date_language to be set to "american".

这篇关于Oracle截止日期为下午/上午的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆