Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display datediff results as Days Hrs and Mins 1

Status
Not open for further replies.

vangundy

Programmer
Jan 29, 2005
38
CA
I am trying to use the datediff fucntion to obtain the diff between two dates and to display it as Days Hrs and Minutes

The results show as:
4 97 5775

When it should show as:
4 0 15

Here is my data being used in my Access query:
Date1 = 2005/06/27 19:45:00
Date2 = 2005/07/01 20:00:00

Days: DateDiff("d",[date1],[date2])
Hours: DateDiff("h",[date1],[date2])
Minutes: DateDiff("n",[date1],[date2])

Expr Duration: [Days] & " " & [Hours] & " " & [Minutes]


 
Duration: Int(DateDiff("d",[date1],[date2])/1440) & " " & Format(DateDiff("d",[date1],[date2])/1440,"h n")


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
the result using your expression is:
0 0 4

Where is the 15 minutes? Should be:
4 0 15
 
OOps, sorry for the typo:
Duration: Int(DateDiff("[highlight]n[/highlight]",[date1],[date2])/1440) & " " & Format(DateDiff("[highlight]n[/highlight]",[date1],[date2])/1440,"h n")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top