Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Day light savings issue
Message
From
09/11/2007 12:16:26
 
 
To
09/11/2007 12:05:21
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01267255
Message ID:
01267969
Views:
20
>>>Hi peter,
>>>
>>>>>>>
>>>>>>>A client called about an incorrect calculation of the time (hrs) between two events. I was calculating the time by using ROUND(DateTime2 - DateTime1)/3600,0). However this does not take into account change of time because of daylight savings.
>>>>>>>
>>>>>>>I'm aware that Windows does store the date and time somewhere on which the daylight saving time change happens. It needs to pick it up from the regional settings as the software is running in many different countries, with and without daylight savings.
>>>>>>>
>>>>>>>Is there an easy way of calcutating the number of hours between two events and taking day light savings into account.
>>>>>>
>>>>>>Suppose datetime1 has been stored in summertime and datetime2 12 REAL hours later in wintertime. Are you implying that your calculation shows 12 hours difference?
>>>>>
>>>>>No, I'm implying that the calculation shows 35 hours while it should have been 36 hrs.
>>>>
>>>>Please use my example. If datetime2 is 12 real hours later, what does your calculation show?
>>>
>>>Your example will show 11 hours difference, while it should have been saying 12.
>>
>>So, it's actually taking day light savings into account. And you are interested in a calculation that does NOT take them into account, right? Then I understand your problem. Do you already have the solution?
>
>Not really, In order to solve this particular problem I need to go into the API.... I did not have the time yet. I was hoping someone has dealt with it before, now I have to work on my own solution.

I assume you stored the datetime() values in the table(s). So you don't have the 'real' times (like the OS has when storing file creation and modification times internally). The problem then is:

At the time of storing the datetime, was the flag for 'Automatically adjust the time for daylight saving' set, yes or no?

It's my hunch that you have to admit: I don't know, because the application runs on many computers and I have no way to find out.

In that case, there's an unrecoverable problem for past time recordings.
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Reply
Map
View

Click here to load this message in the networking platform