QT: How do I subtract clocktimes?
Brian Yennie
briany at qldlearning.com
Thu Sep 20 18:07:54 EDT 2007
As an alternative "manual" method, you could also do the subtraction
yourself. This is untested, but should work - and gives you total
control over any conversion oddities. Just subtract the individual
parts, and if you get a negative minutes portion, roll off another hour.
set the itemDelimiter to "."
put (item 1 of t1 - item 1 of t2) into item 1 of t3
put (item 2 of t1 - item 2 of t2) into item 2 of t3
if (item 2 of t3 < 0) then
subtract 1 from item 1 of t3
add 60 to item 2 of t3
end if
> William,
>
> The easiest way to do time and date math is to convert the times or
> dates to seconds, do the calculations, then convert them back to
> time or date. So to subtract hours (This is assuming time format
> for the system is set properly; U.S. would use colons instead of
> dots):
>
> put "16.00" into t1
> put "7.30" into t2
> convert t1 to seconds
> convert t2 to seconds
> put t1 - t2 into tDiff
> put tDiff div (60*60) into tDiffHours
> put tDiff mod (60*60) into tDiffMins
> put tDiffHours & "." & tDiffMins into tTimeDiff
>
> This is off the top of my head, not tested. But this approach
> should work just fine.
>
> Regards,
>
> Devin
>
>
> Devin Asay
> Humanities Technology and Research Support Center
> Brigham Young University
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
---
Brian Yennie
QLD Learning
More information about the use-livecode
mailing list