Link to home
Start Free TrialLog in
Avatar of tanj1035
tanj1035

asked on

first day & last day of previous week sql query

Hi Experts,

I want to get the first day and last day of previous week.
For example, today is June 2, the first day of previous week is MAY 25, last day  is May 31

First day: Select dateadd(wk, datediff(wk, 0, getdate()) - 1, 0)
Last day: ??

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tanj1035
tanj1035

ASKER

hi Dsacker,

Your query is dynamic for any dates.
I am currently looking for a  simple query , like First day: Select dateadd(wk, datediff(wk, 0, getdate()) - 1, 0). But I do not know the query for the last day of previous week. Can you help me on it?

Thanks
Sure. Last day would be:

DATEADD(wk, DATEDIFF(wk, 0, getdate()), 0) - 1