Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Posts
    7

    Unanswered: select sunday date for week 12

    Hi All,

    I have a query which groups and sums:

    SELECT DatePart("ww",ShipDate) as TheWeek,
    LOCNCODE,
    ITEMNMBR,
    Sum(QUANTITY)as TotalQty,
    Sum(QTYORDER)as TotalQtyOrder
    FROM ALL_SOP_ORDERS INNER JOIN ALL_SOP_ORDERS_DTL
    ON ALL_SOP_ORDERS.SOPNUMBE =
    ALL_SOP_ORDERS_DTL.SOPNUMBE
    WHERE ALL_SOP_ORDERS.ShipDate >= '1/5/2003'
    GROUP BY TheWeek,LOCNCODE,ITEMNMBR

    I'd like to add an additional field which would display that Sundays
    date for TheWeek.

    For instance, if Shipdate was 1/7/2003 and TheWeek is 2 then I'd like to display that Sunday, 1/5/2003.

    Thanks for any help,
    G West

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    Select dateadd(dd, -1 * datepart(dw, ShipDate) + 1, shipdate) as Sunday

  3. #3
    Join Date
    Nov 2002
    Posts
    7
    Thank You ! I would have never gotten that one ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •