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 |
|
rc1138
Starting Member
35 Posts |
Posted - 2010-05-30 : 21:46:37
|
| Hi all, I'm trying to calculate the day difference between the current date and the last known update to a column. I might be going over this particular query the wrong way howeverI have this table called irActivity and in it is a column calledirActDateMy query is as followsSELECT COUN(DATEDIFF(DAY,irActDate,GETDATE())) AS DAYSFROM irActivityIt produces this resultDays6But the last entry in my irActDate column is 1/1/1997 so there should be thousands of days as the difference between 1/1/1997 and todays date*1/1/1997 is the last entry of the column so I'm thinking that part of the syntax may be wrong as well. By putting the name of the column in the condition will it automatically take the last entry ? Thanks again ! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-05-30 : 21:59:36
|
quote: SELECT COUNT(DATEDIFF(DAY,irActDate,GETDATE())) AS DAYSFROM irActivity
You are counting the number of record in the table irActivity in the above query. maybe you wanted this ?select datediff(day, max(irActDate), getdate()) as DAYSfrom irActivity KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
rc1138
Starting Member
35 Posts |
Posted - 2010-05-30 : 22:26:55
|
| Thats exactly it thanks! |
 |
|
|
|
|
|