rj********@hotmail.com wrote:
Hey,
Today is Thursday 16-Feb-06. The same thursday last year is 17-Feb-05.
Because I am comparing daily sales between years, I need to know the
date of the same weekdayname as last year, so that I am comparing
Saturdays with Saturdays, Sundays with Sundays, etc
ie, 16-feb-06 goes to 17-feb-05
28-july-06 goes to 27-july-05 and so on
I have tried all sorts of dateadd('2004-01-01'............. etc, and I
am all out of ideas.
What exactly do you mean by 'the same thursday'?
Is it the third thursday in february? If so, how do you handle the
fifth xxx of february in a leap year?
Is it the thursday of week number n? If so, when does week 1 start?
First day of january? Then weeks start on different days in different
years.
First saturday (or sunday or wednesday...) of january? Then is it week
0 before that? Or week 53 of the previous year?
Depending on your defiinition of 'same', the answers will be different.
DAYOFYEAR and DAYNAME('2006-01-01') might be helpful.
--
Eric Lafontaine