在 Oracle 中将希伯来月份名称转换为英文月份名称

发布于 2024-10-14 23:45:42 字数 625 浏览 3 评论 0原文

我必须接受用户输入的希伯来语(月份名称)并将其转换为英文月份名称。有没有办法在没有查找表的情况下转换它(也许使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紫南 2024-10-21 23:45:42

这是我想到的第一件事。我不知道足够的希伯来语来测试希伯来语值,但这似乎适用于挪威语:

with test_norwegian as (
  select 'januar' month
  from dual
)
select 
to_char(
  to_date('1 '||test_norwegian.month||' 2011', 'dd month yyyy', 'NLS_DATE_LANGUAGE=NORWEGIAN')
  , 'month', 'NLS_DATE_LANGUAGE=NORWEGIAN') norwegian_month
,to_char(
  to_date('1 '||test_norwegian.month||' 2011', 'dd month yyyy', 'NLS_DATE_LANGUAGE=NORWEGIAN')
  , 'month', 'NLS_DATE_LANGUAGE=AMERICAN') american_month
from test_norwegian

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:

with test_norwegian as (
  select 'januar' month
  from dual
)
select 
to_char(
  to_date('1 '||test_norwegian.month||' 2011', 'dd month yyyy', 'NLS_DATE_LANGUAGE=NORWEGIAN')
  , 'month', 'NLS_DATE_LANGUAGE=NORWEGIAN') norwegian_month
,to_char(
  to_date('1 '||test_norwegian.month||' 2011', 'dd month yyyy', 'NLS_DATE_LANGUAGE=NORWEGIAN')
  , 'month', 'NLS_DATE_LANGUAGE=AMERICAN') american_month
from test_norwegian
满天都是小星星 2024-10-21 23:45:42

根据对维基百科文章:希伯来历的快速扫描,似乎有理由说希伯来历其运作方式与公历不同。示例包括:

  • 公历 5771 年没有闰月。
  • 公历月份的长度是固定的。由于它们基于月球周期,因此并非所有希伯来月份都是固定长度的。

如果您想在希伯来语和公历月份名称之间进行转换,您首先需要从希伯来语日期转换为公历日期,然后确定公历月份。

谷歌搜索“从希伯来语日期转换为公历” 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:

  • There is no leap month in the Gregorian calendar for the year 5771.
  • Gregorian months are fixed length. Since they are based on lunar cycles, not all Hebrew months are fixed length.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文