I'm not sure if I am doing something wrong, or if sqlserver's datediff() function doesn't calculate the way that I expect it to.
Example:
select datediff(yy,{ts '2002-12-31 00:00:00'},{ts '2003-01-01 00:00:00'});
The statement above returns a value of "1". Which, in my opinion, is not what the value should be. Intuitively, I would expect a value of "0" to be returned due to the fact that the difference of the two dates is only "1 day" not "1 year". Apperantly, sqlserver simply finds the difference of the years of each datetime value and disregards the months/days/time.
Assuming that this is simply the way SqlServer implements the datediff() function, does anyone know of a work-around or another function that when I calculate the difference of two dates the entire datestamp is used in the calculation - not just the datepart?
tia
Example:
select datediff(yy,{ts '2002-12-31 00:00:00'},{ts '2003-01-01 00:00:00'});
The statement above returns a value of "1". Which, in my opinion, is not what the value should be. Intuitively, I would expect a value of "0" to be returned due to the fact that the difference of the two dates is only "1 day" not "1 year". Apperantly, sqlserver simply finds the difference of the years of each datetime value and disregards the months/days/time.
Assuming that this is simply the way SqlServer implements the datediff() function, does anyone know of a work-around or another function that when I calculate the difference of two dates the entire datestamp is used in the calculation - not just the datepart?
tia