SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Issue with trying to incorporate the following SELECT DATEPART(WEEKDAY, GETDATE())


Issue with trying to incorporate the following SELECT DATEPART(WEEKDAY, GETDATE())

Author
Message
steve4134
steve4134
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 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.


only4mithunc
only4mithunc
Right there with Babe
Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)

Group: General Forum Members
Points: 752 Visits: 2803
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
steve4134
steve4134
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 23
Thank you very much. This was the fix I needed. Thank you again.

Steve
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search