Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-08-20 : 07:17:35
|
| hi,I want to find the difference between two columns whose datatype is datetime in terms of noofdaysandtime.Please help me.Thanks... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-20 : 07:22:10
|
| Read about datediff function in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-08-20 : 07:25:29
|
quote: Originally posted by madhivanan Read about datediff function in sql server help fileMadhivananFailing to plan is Planning to fail
i know how to find interms of noofdays for eg select datediff(day,fromdate,todate)but i want accurated diff between two dates in terms of noofdays along with time..plz help |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-20 : 07:28:36
|
quote: Originally posted by raky
quote: Originally posted by madhivanan Read about datediff function in sql server help fileMadhivananFailing to plan is Planning to fail
i know how to find interms of noofdays for eg select datediff(day,fromdate,todate)but i want accurated diff between two dates in terms of noofdays along with time..plz help
Can you post some sample and expected result?MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-20 : 08:21:04
|
quote: Originally posted by raky
quote: Originally posted by madhivanan Read about datediff function in sql server help fileMadhivananFailing to plan is Planning to fail
i know how to find interms of noofdays for eg select datediff(day,fromdate,todate)but i want accurated diff between two dates in terms of noofdays along with time..plz help
if you want the accuracy in terms of hourthen use dateadiff(hour, fromdate, todate)or up to minutedateadiff(minute, fromdate, todate) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-20 : 09:23:40
|
| [code]SELECT CAST(DATEDIFF(ss,StartDate,EndDate)/86400 AS varchar(10))+ ' Days'+ CAST((DATEDIFF(ss,StartDate,EndDate)%86400)/3600 AS varchar(10)) + ' Hours'+CAST(((DATEDIFF(ss,StartDate,EndDate)%86400)%3600)/60 AS varchar(10)) + ' Minutes'+CAST((((DATEDIFF(ss,StartDate,EndDate)%86400)%3600)/60)%60 AS varchar(10)) +' Seconds'[/code] |
 |
|
|
|
|
|
|
|