Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Daylight Saving Time (DST) and calculating time difference.
The elapsed time between two time values are not affected by DST.
Dim StartTime As Date Dim EndTime As Date Dim ElapsedTime As Date EndTime = TimeSerial(18, 0, 0) ' 6:00 PM StartTime = TimeSerial(12, 0, 0) ' Noon ElapsedTime = EndTime - StartTime ' 6 Hours Debug.Print Format(ElapsedTime, "hh:mm:ss") Where and in what way would DST possibly affect the calculation above? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Blue Knight" <Blue wrote in message ... We use excel to track the number of hours / minutes from the placing of a order and when it was complete. It appears that excel does not take in the new US daylight saving time into affect when looking at elasped time or time range calculation. Are there any patches being planned by microsoft specifically for excel or access or sql for use with the new daylight saving time? (So that from Noon on Saturday to Noon on Sunday will count as 23 and not 24 hours) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Daylight Saving Time (DST) and calculating time difference.
You could see my page on Local And GMT Times
(http://www.cpearson.com/excel/LocalAndGMTTimes.htm) which also discusses DST and the GetTimeZoneInformation API function. There is no built-in function, neither in VB/VBA nor in the Windows API library that will determine whether a date/time is within DST. The downloadable code contains such a function. The closest you can get with the Windows API is whether the current date and time is within DST. The GetTimeZone information indicates whether the current date and time is within DST, and in the TIME_ZONE_INFORMATION structure provides the bias (typically +/- 60 minutes) used when converting to/from DST, but does not contain the date/times on which the transition is made. See http://msdn2.microsoft.com/en-gb/library/ms724421.aspx for information about GetTimeZoneInformation. But as you correctly point out, there will be an ambiguity that cannot be definitively solved. If the time is 01:30:00 AM on the Sunday on which DST changes to Standard Time, it is impossible to know whether that 01:30:00 AM value has been convert from DST to Standard time. It may be either Standard or DST time. There is no way to know. Also, the time 02:30:00 AM on the Sunday on which Standard Time changes to DST is a non-existent time. At 2AM, the time changes to 3AM, so 2:00:00 AM to 2:59:59 AM on that day is non-existent. The page on my web cited above also contains a downloadable file with about 20 function related to GMT, Local Time, and DST. Also, note that the rules for DST are changing in 2007. DST in years 2007 and later years begins on the second Sunday of March, not the first Sunday in April. I was unaware of this fact until I began researching for the code on the web site. My code takes this rule change into account. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Martin Fishlock" wrote in message ... I think the person is talking about time straddling two days when DST comes into effect. Say: start_time=13:00 on the Saturday when DST is actioned end_time=13:00 on the Sunday following DST Therefore there may be 25 or 23 hours in that time period due to moving the clocks back or forward. I don't have DST in Thailand so I can't check. I know that on 'date and time' on control panel there is automatically adjust for DST in time zones where there is DST. But I suspect that as was stated that the time would be reported as 24 and not 23 or 25. The solution is to adjust the time calculations for periods stradding that DST shift. Not very good but...... -- Hope this helps Martin Fishlock, Bangkok, Thailand Please do not forget to rate this reply. "Chip Pearson" wrote: The elapsed time between two time values are not affected by DST. Dim StartTime As Date Dim EndTime As Date Dim ElapsedTime As Date EndTime = TimeSerial(18, 0, 0) ' 6:00 PM StartTime = TimeSerial(12, 0, 0) ' Noon ElapsedTime = EndTime - StartTime ' 6 Hours Debug.Print Format(ElapsedTime, "hh:mm:ss") Where and in what way would DST possibly affect the calculation above? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Blue Knight" <Blue wrote in message ... We use excel to track the number of hours / minutes from the placing of a order and when it was complete. It appears that excel does not take in the new US daylight saving time into affect when looking at elasped time or time range calculation. Are there any patches being planned by microsoft specifically for excel or access or sql for use with the new daylight saving time? (So that from Noon on Saturday to Noon on Sunday will count as 23 and not 24 hours) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calculating time difference | Excel Discussion (Misc queries) | |||
Calculating Difference in Time (Amt. of Time Transpired) | Excel Discussion (Misc queries) | |||
calculating time difference | Excel Worksheet Functions | |||
calculating difference in time | Excel Discussion (Misc queries) | |||
Time difference calculations, daylight savings time, Excel | Excel Discussion (Misc queries) |