caluculating hours differance between two dates

H

hemanth

i want caluculate difference between two dates if it is more than 24 hrs it
is become zero later hours are displaying in caluculation in access table or
in form pl solve my problem
 
J

JethroUK©

pseudo code

Format(todate-fromdate,"[HH]:nn")

should return the difference in whole hours (not days)
 
D

Duane Hookom

With date only values, this expression would only display 00:00. It would
never display 33:00 or 11:00 or 48:00. I believe Jeff has hinted at the
correct solution for determining the number of time intervals (hrs, minutes,
seconds, days, weeks,...) between to date/time values.
--
Duane Hookom
MS Access MVP

JethroUK© said:
pseudo code

Format(todate-fromdate,"[HH]:nn")

should return the difference in whole hours (not days)


hemanth said:
i want caluculate difference between two dates if it is more than 24 hrs it
is become zero later hours are displaying in caluculation in access table or
in form pl solve my problem
 
T

Tim Ferguson

Format(todate-fromdate,"[HH]:nn")

should return the difference in whole hours (not days)

Pretty close, but it's an Excel format not a VBA one. This works:

(CDbl(toDate) - CDbl(fromDate)) * 24


Tim F
 
J

JethroUK©

i was assuming he was using date/time values as 'to' and 'from'


Duane Hookom said:
With date only values, this expression would only display 00:00. It would
never display 33:00 or 11:00 or 48:00. I believe Jeff has hinted at the
correct solution for determining the number of time intervals (hrs, minutes,
seconds, days, weeks,...) between to date/time values.
--
Duane Hookom
MS Access MVP

JethroUK© said:
pseudo code

Format(todate-fromdate,"[HH]:nn")

should return the difference in whole hours (not days)


hemanth said:
i want caluculate difference between two dates if it is more than 24
hrs
it
is become zero later hours are displaying in caluculation in access
table
or
in form pl solve my problem
 
J

JethroUK©

could you not use:

CDbl(toDate - fromDate) * 24


Tim Ferguson said:
Format(todate-fromdate,"[HH]:nn")

should return the difference in whole hours (not days)

Pretty close, but it's an Excel format not a VBA one. This works:

(CDbl(toDate) - CDbl(fromDate)) * 24


Tim F
 
T

Tim Ferguson

could you not use:

CDbl(toDate - fromDate) * 24

Depends what you mean by "could"... both versions give the same answer as

(toDate - fromDate) * 24

but with anybody with an ounce of programming nous, there is very little
argument about which one is "right".

All the best


Tim F
 

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