Syntax of a date function combination

  • I was hoping someone could suggest code for this SP. OK here is what I am trying to do:

    I need to sum rows in a column (hours) based on a date range (work_date). The SP will run once a week and should consider all the rows for that previous week (Mon - Fri).

    So I am struggling with the getdate() subtracting the days to get to the previous week then considering just row entered in that week.

    Any help is appreciated.

  • a hint

    select

    getdate()

    , datepart( wk, getdate()) 'this week'

    , datepart( wk, getdate()) - 1 'this week'

    , datepart( dw, getdate()) 'day of week'

    You want to work on the week # being one before the current one. Also qualify the day of the week as being >= Mon (2) and <= Fri (6)

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

    http://www.dkranch.net

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

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