DennisTheMenace
IS-IT--Management
There is a GREAT FAQ on dates in SQL found here by Robyn Page
According to the FAQ, DATEPART allows you to figure out what week and day it is:
Does anyone know how to figure out the same date last year based on that? For example the above date used is: October 12th, 2006 which DATEPART breaks down as Thursday (weekday 4) of the 42nd Week of the year 2006.
With that information, I need to go the OTHERWAY. I am trying to get the date that would match in the previous year: The Thursday of the 42nd Week in the year 2005.
Obviously we don't just subtract 365...
Thanks in advance for any help!
-Dennis
=====================
Remember - YOU ARE UNIQUE!!!... Just like EVERYONE ELSE! ;o)
According to the FAQ, DATEPART allows you to figure out what week and day it is:
FAQ said:SELECT DATEPART(YEAR,GETDATE()) --2006
SELECT DATEPART(quarter,GETDATE()) --4
SELECT DATEPART(MONTH,GETDATE()) --10
SELECT DATEPART(dayofyear,GETDATE()) --285
SELECT DATEPART(DAY,GETDATE()) --12
SELECT DATEPART(week,GETDATE()) --42
SELECT DATEPART(weekday,GETDATE()) --4
SELECT DATEPART(hour,GETDATE()) --9
SELECT DATEPART(minute,GETDATE()) --32
SELECT DATEPART(second ,GETDATE()) --8
SELECT DATEPART(millisecond,GETDATE()) --875
Does anyone know how to figure out the same date last year based on that? For example the above date used is: October 12th, 2006 which DATEPART breaks down as Thursday (weekday 4) of the 42nd Week of the year 2006.
With that information, I need to go the OTHERWAY. I am trying to get the date that would match in the previous year: The Thursday of the 42nd Week in the year 2005.
Obviously we don't just subtract 365...
Thanks in advance for any help!
-Dennis
=====================
Remember - YOU ARE UNIQUE!!!... Just like EVERYONE ELSE! ;o)