Jordan Martin
SSC Rookie
Points: 39
More actions
July 21, 2004 at 3:19 pm
#83442
I am trying to filter for all records dated in the exact same week one year ago. I know the datepart(week, [date]) returns the week of the year, but I can't figure out how to turn that into a date range to search by. Any ideas?
JourneymanProgrammer
SSCommitted
Points: 1546
July 21, 2004 at 4:47 pm
#515545
Hey Jordan,
SQL for this might be something like this:
SELECT
*
FROM
Some_Dates_Table
WHERE
DATEDIFF(year, someDate, GETDATE() ) = 1 AND
DATEPART(week, someDate) = DATEPART(week, GETDATE() )
JP
July 21, 2004 at 5:14 pm
#515546
GENIUS!
Why didn't I think of that?
Works like a charm! Thank you very much.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply