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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need a Date Difference 1

Status
Not open for further replies.

LeonelSanchezJr

Programmer
Jan 26, 2001
522
US
I've tried the datediff() function, but that gives me a choice of hours or minutes.

I need to find out how many days, hours and minutes have elapsed between a start datetime field and an end datetime field.

How can I do this.
 

Try this SQL code.

Select
datediff(day,StartDate,EndDate)/24 As NoDays,
Datediff(hour,StartDate,EndDate) % 24 As NoHrs,
Datediff(minute,StartDate,EndDate) % 60 As NoMins
From tbl

Note: % is the modulo operator in T-SQL. Terry Broadbent


"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top