Difference between date and times

B

bob

Hi how do I work out the difference between to dates and times based on 24
hrs being one day

20/07/08 11.00 hrs on hire - 28/07/08 13.00 hrs off hire would be 9 days
because it has gone past the 11.00 hrs

I use the following in my field txtDateCharge
=Int([OffHireDate]-[OnHireDate]) which gives me the result of 8 days

How do I get it to work on a 24 hr basis so if it was greater than 192 hrs
in this case it would show 9 days.

Thanks Bob
 
D

Dirk Goldgar

bob said:
Hi how do I work out the difference between to dates and times based on 24
hrs being one day

20/07/08 11.00 hrs on hire - 28/07/08 13.00 hrs off hire would be 9 days
because it has gone past the 11.00 hrs

I use the following in my field txtDateCharge
=Int([OffHireDate]-[OnHireDate]) which gives me the result of 8 days

How do I get it to work on a 24 hr basis so if it was greater than 192 hrs
in this case it would show 9 days.


It seems to me that your problem is not really one of calculating the
difference, but rather of rounding up to the next full day. For that, in
this simple case, maybe this simple expression would suffice:

=Int([OffHireDate] - [OnHireDate] + 0.99999)

That is, of course, based on the understanding that the dates you are
working with are stored internally as a double-precision number with the
integer part representing the number of days since the "zero date", and the
fractional part representing the time as a fraction of a day. So this logic
is definitely specific to Access and Jet.
 
B

bob

Thanks Dirk problem sorted.

Regards Bob
Dirk Goldgar said:
bob said:
Hi how do I work out the difference between to dates and times based on
24 hrs being one day

20/07/08 11.00 hrs on hire - 28/07/08 13.00 hrs off hire would be 9
days because it has gone past the 11.00 hrs

I use the following in my field txtDateCharge
=Int([OffHireDate]-[OnHireDate]) which gives me the result of 8 days

How do I get it to work on a 24 hr basis so if it was greater than 192
hrs in this case it would show 9 days.


It seems to me that your problem is not really one of calculating the
difference, but rather of rounding up to the next full day. For that, in
this simple case, maybe this simple expression would suffice:

=Int([OffHireDate] - [OnHireDate] + 0.99999)

That is, of course, based on the understanding that the dates you are
working with are stored internally as a double-precision number with the
integer part representing the number of days since the "zero date", and
the fractional part representing the time as a fraction of a day. So this
logic is definitely specific to Access and Jet.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top