Results 1 to 5 of 5
  1. #1
    Join Date
    May 2004
    Posts
    16

    Unanswered: Grouping by week of the month

    How to grouping data by week number of the month (1-5) instead week of the year (1-53)?

  2. #2
    Join Date
    Mar 2003
    Location
    Bogota
    Posts
    67
    there's probably a better way, but this seems to work:

    (cint(format(<date>,"dd")) \ 7) + (abs(cint(cbool(cint(format(<date>,"dd")) mod 7))))

    Just substitute the date expression. Notice the backslash, too (not forward slash)

  3. #3
    Join Date
    May 2004
    Posts
    16
    There is a problem with it. It returns 2 instead of 3 for week 3.

    Quote Originally Posted by pd9n
    there's probably a better way, but this seems to work:

    (cint(format(<date>,"dd")) \ 7) + (abs(cint(cbool(cint(format(<date>,"dd")) mod 7))))

    Just substitute the date expression. Notice the backslash, too (not forward slash)

  4. #4
    Join Date
    Mar 2003
    Location
    Bogota
    Posts
    67
    This is what it gives you, which seems right to me:

    1-7 >> week 1
    8-14 >> week 2
    15-21 >> week 3
    22-28 >> week 4
    29-31 >> week 5

  5. #5
    Join Date
    May 2004
    Posts
    16
    Thank you.

    Quote Originally Posted by pd9n
    This is what it gives you, which seems right to me:

    1-7 >> week 1
    8-14 >> week 2
    15-21 >> week 3
    22-28 >> week 4
    29-31 >> week 5

Posting Permissions

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