Results 1 to 4 of 4
  1. #1
    elandy is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    2

    Sort Week number

    I have a simple problem and i couldn't find the answer anywhere.

    I have a CrossQuery sum some values by weekNumber

    (yyyy/ww)



    Week Number | Jason | Bourne | Neo |
    2017/23 | | | |
    2017/36 | | | |
    2017/47 | | | |
    2017/50 | | | |
    2018/1 | | | |
    2018/10 | | | |
    2018/11 | | | |
    2018/2 | | | |
    2018/23 | | | |

    How to sort by week number? Like This

    Week Number | Jason | Bourne | Neo |
    2017/23 | | | |
    2017/36 | | | |
    2017/47 | | | |
    2017/50 | | | |
    2018/1 | | | |
    2018/2 | | | |
    2018/10 | | | |
    2018/11 | | | |
    2018/23 | | | |

    Thanks,
    Elandy

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Despite its name, your Week Number field is a text string due to the '/'
    So its correctly sorting each character as text in turn
    To fix, you need two other number fields YearNo & WeekNo and sort by both of those fields instead.
    The two fields can be hidden if you wish
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    elandy is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    2
    Many thanks!
    It work
    I used Expr1: PartData("yyyy";[fieldname])
    and
    Expr2: PartData("ww";[fieldname])

    i sorted this to filds and hidden!

  4. #4
    Join Date
    Apr 2017
    Posts
    1,680
    A simpler way is format the week number like
    '2018/01'
    or
    201801
    i.e. the week number itself is always 2 numbers. This allows to apply correct sorting for either of formats.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Week Number
    By Brightspark98 in forum Programming
    Replies: 10
    Last Post: 01-14-2017, 08:20 AM
  2. Replies: 2
    Last Post: 04-14-2016, 06:30 PM
  3. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  4. How to sort Day of week from Monday to Saturday
    By ultra5219 in forum Queries
    Replies: 3
    Last Post: 02-20-2013, 06:52 AM
  5. Week number wrong
    By Nikki17 in forum Queries
    Replies: 6
    Last Post: 03-18-2006, 10:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums