SELECT DATEADD(day, (DATEPART(week, GETDATE()) * 7
+ DATEPART(weekday, GETDATE()))
- (DATEPART(week, DATEADD(year, -1, GETDATE())) * 7
+ DATEPART(weekday, DATEADD(year, -1, GETDATE()))), DATEADD(year, -1, GETDATE())) as LastYearDate
RESULT
LastYearDate
2008-05-22 11:14:26.350
Did you like this post?
|
|
|
||
|
|
|
|
|
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |




comments
0 Responses to "Finding the date last year based on the current week and weekday using SQL Server"Post a Comment