PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → 15H00 + 15H00 = 6H00 ?
15H00 + 15H00 = 6H00 ?
Débuté par Pat Biker, 30 nov. 2004 15:27 - 4 réponses
Posté le 30 novembre 2004 - 15:27
Hi,
Unbelievable but true, 6H00 is indeed the result of adding 15H00 and 15H00.
This little piece of code shows that.
d1 is Duration = "0150000000"
d2 is Duration

d2 = d1 + d1
Info(d2..Hour)

Is it not a Gotcha ? I'am afraid it is!
Bye
Pat Biker
Posté le 30 novembre 2004 - 15:44
G'day Pat
Here is an alternate view
Given that you are dealing with hours and minutes then you could also argue that 15hours + 15 hours = 30hours
30 hours -24 hours = 6
Could be that equations with hours attempts to give the time for the result.
After all if you add 1 day to the 30th of November the result is not 32, it is 1, as in the first of December
Regards
Al
Posté le 30 novembre 2004 - 16:32
Hi,
Unbelievable but true, 6H00 is indeed the result of adding 15H00 and 15H00.
This little piece of code shows that.
d1 is Duration = "0150000000"
d2 is Duration

d2 = d1 + d1
Info(d2..Hour)

Is it not a Gotcha ? I'am afraid it is!
Bye
Pat Biker

I don't agree that it's a Gotcha but I certainly concede that it's a bit fiddly.
Here's your code with slight amendments
d1 is Duration = StringToDuration("0150000","DHHMMSS")
d2 is Duration
d2 = d1 + d1
Info(DurationToString(d2,"DHHMM"))
The pictures can be set up how you want them. For instance if you want to include hundredths of a second, put "LL" into the picture.
You will end up with a result in days, hours and minutes (and seconds and parts thereof if you wish). You can then string slice this to get the day component, multiply this by 24 and add the hours component, to get the total number of hours. It's a bit messy I agree but it works OK.
I had thought that there was a simple picture or function which produced a result simply in hours but having looked through the Help file, I can't find this so I think I must be confusing it with one of the spreadsheet packages which does now allow you to format in hours only, not days and hours.
Hope this helps.
Chris L
Melbourne, Oz
Posté le 30 novembre 2004 - 18:07
Hello Pat,
I think that you did overlock something (the 1 in front of the 06). The result of your code is "1060000000" which means: 1 Day and 6 hours. 15 h + 15 h is indeed 30 h and that's 1 day and 6 hours.
HTH
Raimund
Hi,
Unbelievable but true, 6H00 is indeed the result of adding 15H00 and 15H00.
This little piece of code shows that.
d1 is Duration = "0150000000"
d2 is Duration

d2 = d1 + d1
Info(d2..Hour)

Is it not a Gotcha ? I'am afraid it is!
Bye
Pat Biker



http://www.invitec.com
Posté le 01 décembre 2004 - 08:25
Hi Chris,
CHRIS >I had thought that there was a simple picture or function which
CHRIS >produced a result simply in hours but having looked through the
CHRIS >Help file, I can't find this
I think too that some functions are missing in the WLangage. I suggested some of them on my site, like DurationInHour, which could have returned 30H00 in the present case. Or some new properties, something like ..HourCount. However it would not fit the common need to add hours. A teacher, for example, will want to add the duration of its lessons and get a result in a form like 110H30 or 110,5H.
I'm not sure which way is best, but I'm certain some improvements are needed to easy handling duration, date and time calculations.
Ciao
http://wdgotcha.atspace.com