Daylight Savings Time dates 
Author Message
 Daylight Savings Time dates

HI,

Is there a "neat" way to programatically determine the beginning and
end dates for daylight savings time... for any year?

Thanks,

George



Sun, 04 Aug 2002 03:00:00 GMT  
 Daylight Savings Time dates
The following routine was developed in response to another post that once
asked about finding when DayLightSavingsTime began and ended.

I developed the following function which, if your stated conditions are
correct (I didn't feel like looking it up), returns a Date value for either
the beginning or end daylight savings time. The function takes two
arguments, the year you are interested in and a single character, "B" for
the beginning (first day) and "E" for end (last day) of daylight savings
time. Just paste this in the (General)(Declarations) section of a form or a
BAS Module if global scope is needed.

Function DST(YearIn As Variant, _
             BeginEnd As String) As Date
  If InStr("BE", UCase(BeginEnd)) = 0 Then
    DST = 0
  ElseIf UCase(Left$(BeginEnd, 1)) = "B" Then
    DST = DateAdd("d", (8 - WeekDay("4/1/" & _
          CStr(YearIn))) Mod 7, "4/1/" & CStr(YearIn))
  Else
    DST = DateSerial(CInt(YearIn), 10, _
          32 - WeekDay(DateAdd("d", -1, "11/1/" _
          & CStr(YearIn))))
  End If
End Function

I guess I should have mentioned, an improper Begin/End specifier returns
"12:00:00 AM" as an error indicator (because DST returns a Date value).
Also, one glitch (very minor -- I'll let you correct for it if you want),
there is one occasion when more than one character is acceptable in BeginEnd
argument, when it is "BE". However, if you enter that, DST will treat it as
"B".

Also, because DST returns a Date value, you can do date math on it, but of
course you realized that.

And finally, you are aware that not every state observes daylight savings
time and in some cases part of some states observe it whereas other parts
don't, right?

Rick


Quote:
> HI,

> Is there a "neat" way to programatically determine the beginning and
> end dates for daylight savings time... for any year?

> Thanks,

> George



Sun, 04 Aug 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Daylight Saving Time and computing difference between two dates

2. Daylight saving - winter time - summer time - time zone

3. Daylight saving - winter time - summer time - time zone

4. Daylight saving - winter time - summer time - time zone

5. time zones and daylight saving time

6. Standard Time or Daylight Savings Time

7. Standard v. Daylight Savings Time Function

8. Daylight Savings Time Error

9. Daylight Savings Time

10. Daylight Savings-Time bias

11. Daylight Savings Time

12. how to calculate daylight saving time ?

 

 
Powered by phpBB® Forum Software