Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating time difference jbly Excel Discussion (Misc queries) 14 August 15th 08 03:09 PM
Calculating Difference in Time (Amt. of Time Transpired) WOLLAM Excel Discussion (Misc queries) 4 June 27th 08 03:54 PM
calculating time difference Michel Khennafi Excel Worksheet Functions 1 January 31st 08 02:37 PM
calculating difference in time tam25 Excel Discussion (Misc queries) 4 September 7th 07 09:26 AM
Time difference calculations, daylight savings time, Excel Tim Excel Discussion (Misc queries) 1 December 28th 06 04:18 PM


All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"