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

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

我们使用以下两个函数来计算任何给定年份的开始和结束日期(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.