Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Issue with trying to incorporate the following SELECT DATEPART(WEEKDAY, GETDATE()) Expand / Collapse
Author
Message
Posted Wednesday, October 20, 2010 8:19 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, November 22, 2013 12:34 PM
Points: 9, Visits: 23
Hey All

I am new to SQL development and come from a help desk background. This is one of my first projects and I am stuck. My out come would be to use the- SELECT DATEPART(WEEKDAY, GETDATE())- into a current table I have set up. The following code attached is what I am working with. My outcome would be to create another column next to my results with numeric values next to the dates. I am stuck by only getting the current date but I would like it to go for my whole selected date range. Any help is appreciated. This screen shot was from yesterday so I understand today would be 4 and so on.

Steve

SELECT * FROM ##salesdays

EXCEPT

SELECT date FROM dbo.csta_non_working_days


SELECT DATEPART(WEEKDAY, GETDATE())


This gives me the following results below in the image.


Post #1007768
Posted Wednesday, October 20, 2010 10:08 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, February 20, 2013 9:40 AM
Points: 358, Visits: 2,775
Hi try this,

SELECT dateRange,DATEPART(WEEKDAY,dateRange)as Week_day
from
(
SELECT dateRange FROM ##salesdays
EXCEPT
SELECT date FROM dbo.csta_non_working_days
) as t



Thanks & Regards,
MC
Post #1007859
Posted Wednesday, October 20, 2010 1:01 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, November 22, 2013 12:34 PM
Points: 9, Visits: 23
Thank you very much. This was the fix I needed. Thank you again.

Steve
Post #1007957
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse