4 Replies Latest reply on Aug 1, 2008 4:32 AM by Hagster

    Weeks Numbers

      Hello All

      Any ideas on the best way to work out what month a particular week is in.

      Im getting my data returned from the SQL server groupped by 'datepart' see below

      So im getting a list of orders totaled by week.

      the week is the week number i.e. wk31 wk32 wk33
      How can I determin what month wk31 falls in for reporting I want to display the month with the apropriat weeks below it.

      Kind Regards Guy
      and thanks for any help in advance.

      ************ SQL for datepart grouping *****************
        • 1. Re: Weeks Numbers
          Dan Bracuk Level 5
          The simplest way is to select the datepart that gives you the month as part of your query. Before doing so, decide what to do about weeks that have two months, this week for example.
          • 2. Re: Weeks Numbers
            Hagster Level 1
            Thanks Dan, obviously its such a simple solution, why do things like this just evade me :)

            Any way being a little lazy here I have set up my SQL to do as you surgested, but have a question with weeks that have two months as this one, how does the MS Server denote which month to put the week into?
            is it the month that the week starts in?

            I will go work it out tomorrow just wondered if you new of top of your head.

            ***** new select below********************

            SELECT MONTH(planned.planddate) AS planmonth, DATEPART(ww, PLANNED.planddate) AS planweek,
            • 3. Re: Weeks Numbers
              Dan Bracuk Level 5
              When I wonder about stuff like that, I code it and try it.
              • 4. Re: Weeks Numbers
                Hagster Level 1
                I know :), thought it was a little cheeky asking.

                Any how thanks for the replys all working and done now.