Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Modify Date To Show Friday To Saturday

Author  Topic 

mmdjs
Starting Member

2 Posts

Posted - 2012-02-29 : 15:24:10

Hi everybody, this is my first post so hopefully I am posting in the right spot i apologize if I am not ,

I have this SP I am working on or modifying so to speak

it currently stores a week of field in my tempresults table but the problem I am having is i also have a parameter for mtd as seen in this code here


ELSE IF @Interval = 'M' -- Current Month
BEGIN
SET @Startdate = CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@Startdate)-1),@Startdate),101)
SET @EndDate = CONVERT(VARCHAR(25),DATEADD(DAY,-1,GetDate()))

END

I need my week range to be Friday to Saturday, instead of how it is now here is my week of insert


INSERT INTO #TempResults (Sorter, Week_Of, Row_Date, int_day_key)
SELECT 1,
DatePart(Week,row_date ) as Week_Of,
Convert(Varchar, row_date,101),
day_key
FROM dbo.vw_dim_date (NOLOCK)
Where row_date >= @StartDate
And row_date <= @EndDate

Any chance anyone knows how to modify this really quickly to give me the Friday to saturday range in my results set ?

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-29 : 15:31:16
The Fiday of what week? The week of Start Date?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

mmdjs
Starting Member

2 Posts

Posted - 2012-02-29 : 15:37:35
Well it would be mtd so it would show whatever the first was up until thursday for the first week then start the new week friday to saturday after that.
Go to Top of Page
   

- Advertisement -