Time Calculation

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

Guest

How to time calculate in the following format:
HH:NN:SS
I NEED SYSTEM CALCULATE TIMEDIFF FROM TWO DIFFERENT DATE+TIME FORMAT,

EX: DT1=10-JAN-2005 10:10:11 AM & DT2=11-JAN-2005 11:15:24 AM
RESULT: 25:05:13 (DT2-DT1)

BUT ACCESS RETURN VALUE LIKE 0.797888775252 (I THINK THIS VALUE SHOWN IN Hrs)

GOVIND K MISHRA
DELHI,INDIA
 
Hi,
How to time calculate in the following format:
HH:NN:SS
I NEED SYSTEM CALCULATE TIMEDIFF FROM TWO DIFFERENT DATE+TIME FORMAT,

EX: DT1=10-JAN-2005 10:10:11 AM & DT2=11-JAN-2005 11:15:24 AM
RESULT: 25:05:13 (DT2-DT1)

BUT ACCESS RETURN VALUE LIKE 0.797888775252 (I THINK THIS VALUE SHOWN IN
Hrs)

what's wrong with your shift-key?

Read the doc about the 'DateDiff'-function. There you can specify if you
want the difference to be returned in hours minutes and so on.

Another possibility is to use CDate(Date1 - Date2). May be you want to
format the result for your purposes. Then you have to use
Format(CDate(Date1 - Date2), <your format string>).

Thomas
 
How to time calculate in the following format:
HH:NN:SS
I NEED SYSTEM CALCULATE TIMEDIFF FROM TWO DIFFERENT DATE+TIME FORMAT,

EX: DT1=10-JAN-2005 10:10:11 AM & DT2=11-JAN-2005 11:15:24 AM
RESULT: 25:05:13 (DT2-DT1)

BUT ACCESS RETURN VALUE LIKE 0.797888775252 (I THINK THIS VALUE SHOWN IN Hrs)

GOVIND K MISHRA
DELHI,INDIA

Access date/time values are stored as double float numbers, days and
fractions of a day. Subtracting two dates will give you either a date
(usually a date in 1899, since Date/Time value 0 corresponds to
midnight, December 30, 1899) or a number. Access doesn't provide a
format to display times greater than 24 hours; they show up as times
on the next day - that is, 25:05:13 is actually #12/31/1899 01:05:13#.

To get the display you want, you can use

DateDiff("h", [DT1], [DT2]) & Format(DateDiff("n", [DT1], [DT2]) MOD
60, ":00") & Format(DateDiff("s", [DT1], [DT2]), ":00")

Note that the format of DT1 and DT2 is completely irrelevant; it just
controls how these fields are displayed.

John W. Vinson[MVP]
 
Back
Top