Oracle中是否存在夏令时,在Oracle中,如何检测夏令时开始/结束的日期?

我们使用以下两个函数来计算任何给定年份的开始和结束日期(2007年后,美国).

Function DaylightSavingTimeStart (p_Date IN Date)

Return Date Is

v_Date Date;

v_LoopIndex Integer;

Begin

--Set the date to the 8th day of March which will effectively skip the first Sunday.

v_Date := to_date('03/08/' || to_char(p_Date,'YYYY') || '02:00:00 AM','MM/DD/YYYY HH:MI:SS PM');

--Advance to the second Sunday.

FOR v_LoopIndex IN 0..6 LOOP

If (RTRIM(to_char(v_Date + v_LoopIndex,'DAY')) = 'SUNDAY') Then

Return v_Date + v_LoopIndex;

End If;

END LOOP;

End;

Function DaylightSavingTimeEnd (p_Date IN Date)

Return Date Is

v_Date Date;

v_LoopIndex Integer;

Begin

--Set Date to the first of November this year

v_Date := to_date('11/01/' || to_char(p_Date,'YYYY') || '02:00:00 AM','MM/DD/YYYY HH:MI:SS PM');

--Advance to the first Sunday

FOR v_LoopIndex IN 0..6 LOOP

If (RTRIM(to_char(v_Date + v_LoopIndex,'DAY')) = 'SUNDAY') Then

Return v_Date + v_LoopIndex;

End If;

END LOOP;

End;

可能有一种更简单的方法,但这些对我们有用.当然,此查询不知道是否在您所在的位置观察到夏令时.为此你需要location data.


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部