caluculating hours differance between two dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
pseudo code

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

should return the difference in whole hours (not days)
 
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
 
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
 
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
 
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
 
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
 
Back
Top