Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Weekly Reports Made Easy

By Yul Wasserman, 2013/05/24

Each week you are required to run various reports based on table entries made during the week preceding latest Sunday. Use this SQL7/2000 procedure (can be a UDF in SQL2K) to retrieve the latest midnight of a specified day of the week as illustrated below: Declare @StartDate datetime, @EndDate datetime Exec DBAservice.dbo.uspGetLatestWkDayMidnight @pDate = '1998-05-06', @pWeekDay ='Sunday', @pWDmidnight=@EndDate output Select @StartDate=dateadd(ww,-1,@EndDate) Select * from Northwind.dbo.orders where OrderDate>=@StartDate and OrderDate<@EndDate

Total article views: 254 | Views in the last 30 days: 1
 
Related Articles
FORUM

Parameter Startdate, Enddate validation

SSRS Parmeters : startdate should not be later than enddate

FORUM

Help with TSQL, getting StartDate and EndDate from WeekDate !!!

How to get StartDate and EndDate from WeekDate in a table ????

FORUM

SSRS @StartDate and @EndDate

I was using the date parameter @StartDate and @EndDate , But SQL was executing from the year 19-- ....

FORUM

Insert enddate using startdate

HI, I have two date columns in table , startdate and enddate .Enddaet column is null currently ....

FORUM

records within StartDate and EndDate

i have a "Place" table in which i have three coulmns. StartDate EndDate Place and i have a...

Tags
t-sql    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones