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 |
|
chotup
Starting Member
3 Posts |
Posted - 2008-12-19 : 23:06:32
|
| hi All,I am trying to use datediff fuunction. But problem is that it return interger for the month. Can someone suggest with me some code or function that returns date differnce for months in decimal?Will really appreciate any help on this |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2008-12-19 : 23:08:03
|
| wt is ur requirement can u post some o/p |
 |
|
|
chotup
Starting Member
3 Posts |
Posted - 2008-12-19 : 23:13:55
|
| well like i m using datediff(mm,'10/15/2008', '11/19/2008')it gives me 1, but i need 1.1 here for 4 more days |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-12-19 : 23:47:31
|
| Can you please explain why 4 more days would equal .1 of a month?CODO ERGO SUM |
 |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2008-12-19 : 23:55:07
|
| Try ThisSELECT CASE WHEN DATEDIFF(d,fromdate,enddate)>30 THEN DATEDIFF(d,fromdate,enddate)/30.0 ELSE 0 END AS 'MonthDifference'Jai Krishna |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-20 : 04:47:37
|
SELECT DATEDIFF(DAY, FromDate, EndDate) / 30.436875E E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|