time to time with different dates... 
Author Message
 time to time with different dates...

Hi!

i'm searching for a function that gives the difference in hours between
different days:

example:

dFrom = 22/12/1999  // from date
tFrom = 03:00:00 // from time
dTo = 05/01/2000  // to date
tTo = 16:31:00 // to time

Function Hdiff (dFrom,tFrom,dTo,tTo)
[...]
Return Hours

can you help me?



Thu, 04 Jul 2002 03:00:00 GMT  
 time to time with different dates...

Paul, you can easily write this yourself.  I had to do it a long time
ago, but I have no idea where the code is now.

It'll be something like:

 dFrom = 22/12/1999  // from date
 tFrom = 03:00:00 // from time
 dTo = 05/01/2000  // to date
 tTo = 16:31:00 // to time

 Function Hdiff (dFrom,tFrom,dTo,tTo)

 // the difference in days by minute - 1440 minutes per day
 nDays := ( dTo - dFrom ) * 1440

 // convert each time to minutes
 nFrom := ( val(left(tFrom,2)) * 60) + val(substr(tFrom,4,2)
 nTo   := ( val(left(tTo,2))   * 60) + val(substr(tTo,4,2)

 // then the calculation
 nMinutes := nDays + nTo - nFrom

 nReturn := round( nMinutes/60,0)

 return nReturn

 This is rough and untested, but I'm reasonably sure it'll work.  I did
minutes then divided because of the greater accuracy.  Without doing
that, 16:00 - 15:59 would be an hour, and that's probably not what you
want.  You'll need to add the variable declarations and such yourself
:-)

And test like crazy; don't trust my 2 minute take on your problem :-)
But you can write such functions yourself, and you'll grow from working
it through.

HTH . . . . ed

Quote:

> Hi!

> i'm searching for a function that gives the difference in hours between
> different days:

> example:

> dFrom = 22/12/1999  // from date
> tFrom = 03:00:00 // from time
> dTo = 05/01/2000  // to date
> tTo = 16:31:00 // to time

> Function Hdiff (dFrom,tFrom,dTo,tTo)
> [...]
> Return Hours

> can you help me?



Thu, 04 Jul 2002 03:00:00 GMT  
 time to time with different dates...
Hi
Just think about the Julian calendar !
Find out a conversion function and the others calculs would be easy.

: )

Tony



Thu, 04 Jul 2002 03:00:00 GMT  
 time to time with different dates...
Hi paul,

Quote:

> Hi!

> i'm searching for a function that gives the difference in hours between
> different days:

You can use the functions from JULIAN.ZIP to easily
build one yourself.

You can find JULIAN.ZIP at www.the-oasis.net

HTH
Thomas Braun



Fri, 05 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Create Time / date or Modified Time / date of a txt file

2. convert labview date/time to excel date/time

3. DOS compressed date/time into real date/time

4. TIME&DATE in HTML shows TIME

5. Unix time to calendar date/time?

6. Bug in time.c (was Time.times problems)

7. time and scheduling (was: bug report: [ #447945 ] time.time() is not non-decreasing)

8. time zones, daylight saving time, and universal time

9. Clarion Date (Long) -> Access Date\Time

10. Dos Date & time to clarion date & time

11. Question: how to convert a local Date & Time to UTC Date & Time

12. Print report to two different printers at same time

 

 
Powered by phpBB® Forum Software