Previous Month, Week

by ssi 27. September 2016 15:48

set@StartDate= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())-1, 0)--First day of previous month

set@EndDate  =DATEADD(MONTH, DATEDIFF(MONTH, -1, GETDATE())-1, -1) --Last Day of previous month

    end

else

    begin

set@StartDate=dateadd(dd,((datediff(dd,'17530101',getdate())/7)*7)-7,'17530101') -- Date greater than or equal to Monday of last week

set@EndDate  =dateadd(dd,((datediff(dd,'17530101',getdate())/7)*7)-2,'17530101') -- Date before Saturday of last week

Tags: ,

SQL

Add comment

biuquote
  • Comment
  • Preview
Loading

Calendar

<<  May 2024  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

"Procrastination is, hands down, our favorite form of self-sabotage"
Alyce P. Cornyn-Selby