Thursday, February 1, 2007

Previous week startdate and enddate in SQL Server 2005,SQL Server 2000

s have found the way to get start date and end date of previous week with the help of the date part function of SQL Server 2005. It also work on sql server 2000 also.

Following are the code for finding start date and end date of previous week.

Set @STimeStamp=GETDATE()
set @PStartDate=@STimeStamp-DATEPART(dw,@STimeStamp)-6
set @PEndDate=@STimeStamp-DATEPART(dw,@STimeStamp
)


Happy Programming
Share:

3 comments:

  1. This is awesome code. Thanks a ton for the post.

    ReplyDelete
  2. This code is very helpful. Keep up the good work.

    ReplyDelete
  3. this code is really helpful, thanks a lot

    ReplyDelete

Your feedback is very important to me. Please provide your feedback via putting comments.

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews