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

  • 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.

  • 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

  • Thank you very much. This was the fix I needed. Thank you again.

    Steve

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply