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-05-22 : 10:18:52
|
hi,I HAVE THE FOLLOWING DATADECLARE @D1 DATETIME,@D2 DATETIME SELECT @D1 = '06/05/2005' ,@D2 = '05/22/2008'I NEED TO GET THE DIFFERENCE BETWEEN TWO DATESPLEASE DON'T CONSIDER ONLY YEAR PARTI.E., SELECT DATEDIFF(YEAR,@D1,@D2) IS NOT VALID IN MY CONTEXTI need to consider the days and months also.I need to determine whether the difference is greater than 3 years or not.FOR THE ABOVE GIVEN DATA IT IS LESS THAN 3 YEARS IN THIS CASE I NEED TO GET OUTPUT AS LESS THAN 3 YEARSI ALWAYS ASSIGN @D2 WITH GETDATE().PLEASE HELP ME...THANKS IN ADVANCE... |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-22 : 10:20:04
|
So change it to days to find out how many days there are different. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
|
|
|
|