在 Oracle 中将希伯来月份名称转换为英文月份名称
我必须接受用户输入的希伯来语(月份名称)并将其转换为英文月份名称。有没有办法在没有查找表的情况下转换它(也许使用 to_date 和 to_char)?
更新 - 按照挪威语的建议,我做了这个测试,显示短希伯来语月份名称长于三个字符! (我只能在这个函数中处理三个字符串)
with d as
(
select to_date('01' || lpad(rownum,2,'0') || '2011','DDMMYYYY') d from
(
select 1 from dual connect by level <=12
)
)
select to_char(d.d,'MON','NLS_DATE_LANGUAGE=HEBREW') heb_mon,
to_char(d.d,'MONTH','NLS_DATE_LANGUAGE=AMERICAN') us_mon
from d;
哪个产生了这个数据
ינואר JAN
פברואר FEB
מרץ MAR
אפריל APR
מאי MAY
יוני JUN
יולי JUL
אוגוסט AUG
ספטמבר SEP
אוקטובר OCT
נובמבר NOV
דצמבר DEC
I have to take user input in Hebrew (a month name) and convert it to an English month name. Is there any way to convert this (maybe using to_date and to_char) without a lookup table?
Update - following the suggestion for Norwegian I made this test, showing that the short Hebrew month names are longer than three characters! (I can only handle three character strings in this function)
with d as
(
select to_date('01' || lpad(rownum,2,'0') || '2011','DDMMYYYY') d from
(
select 1 from dual connect by level <=12
)
)
select to_char(d.d,'MON','NLS_DATE_LANGUAGE=HEBREW') heb_mon,
to_char(d.d,'MONTH','NLS_DATE_LANGUAGE=AMERICAN') us_mon
from d;
Which produced this data
ינואר JAN
פברואר FEB
מרץ MAR
אפריל APR
מאי MAY
יוני JUN
יולי JUL
אוגוסט AUG
ספטמבר SEP
אוקטובר OCT
נובמבר NOV
דצמבר DEC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我想到的第一件事。我不知道足够的希伯来语来测试希伯来语值,但这似乎适用于挪威语:
Here's the first thing that came to my mind. I don't know enough hebrew to test with hebrew values, but this seems to work with norwegian:
根据对维基百科文章:希伯来历的快速扫描,似乎有理由说希伯来历其运作方式与公历不同。示例包括:
如果您想在希伯来语和公历月份名称之间进行转换,您首先需要从希伯来语日期转换为公历日期,然后确定公历月份。
谷歌搜索“从希伯来语日期转换为公历” date”产生了大量用于在这些日历之间进行转换的工具。
这是一个可能适用 hebcal 的 sourceforge 项目
Based on a quick scan of the Wikipedia Article: Hebrew calendar it seems reasonable to say that the Hebrew calendar does not operate the same way as the Gregorian calendar. Examples include:
If you want to convert between Hebrew and Gregorian month names, You will first need to convert from a Hebrew date to a Gregorian date then determine the Gregorian month.
A google search for "convert from hebrew date to gregorian date" produces what appears to be a large number of tools for converting between these calendars.
Here is an sourceforge project that may apply hebcal