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

 Page 1 of 1 [ 4 post ]

Relevant Pages