Return current week integer -1 week

  • I am looking to use the GETDATE() function to return the current week integer minus 1 week.

    this is what I came up with but it does not work.

    Select DATEPART(w, GETDATE()) -1

    any help would be appreciated.

  • David,

    you need to use

    Select DATEPART(wk, GETDATE()) -1

    or

    Select DATEPART(ww, GETDATE()) -1

    Kev

  • Although I can't find it in BOL, using 'w' in DATEPART (or DATENAME) returns the day of the week, i.e. the same as using 'dw'.

  • Thanks that looks like it works.

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

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