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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值