Results 1 to 3 of 3
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    week number sorting

    Hi Guys

    i have a query that seperates dates by week number, this works really well.

    but when the query runs the results for the week numbers are as follows

    Week Number
    4
    48
    5

    no matter what sorting i have on the query i can't get the week numbers to go

    Week Number
    4
    5
    48

    this is the query im using
    SELECT Format([unexdata.DueDate],"ww",2) AS [DATE], UNEXProcess.Process, UNEXAreaCapacity.KGPW, Sum(UNEXProcess.QTYOUTST) AS SumOfQTYOUTST, UNEXData.Completed


    FROM (UNEXProcess INNER JOIN UNEXAreaCapacity ON UNEXProcess.Process = UNEXAreaCapacity.Area) INNER JOIN UNEXData ON UNEXProcess.ID = UNEXData.ID
    GROUP BY Format([unexdata.DueDate],"ww",2), UNEXProcess.Process, UNEXAreaCapacity.KGPW, UNEXData.Completed
    HAVING (((UNEXProcess.Process)=[forms]![UnexAreas]![location]) AND ((UNEXData.Completed)=False))
    ORDER BY Format([unexdata.DueDate],"ww",2);


    any help would be brill
    Many thanks

    Steve

  2. #2
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Use DatePart function instead of format.
    DatePart("ww",[unexdata.DueDate])
    DatePart returns integer value, which is sorted properly unlike string returnd from format function.

    Make sure you set additional parameters for this function according to your needs (firstdayofweek, firstweekofyear). Check syntax here: https://msdn.microsoft.com/en-GB/lib...(v=vs.90).aspx

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi cyanidem

    Many thanks for the reply, that worked brill
    and many thanks for the explination, this has to be one of the best sites on the web and thats down to guys like you who use it

    many many thanks
    Steve

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

Similar Threads

  1. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  2. Replies: 4
    Last Post: 07-15-2014, 01:58 PM
  3. Sorting By week
    By BringTheR41n in forum Reports
    Replies: 12
    Last Post: 07-14-2014, 02:57 PM
  4. Week number - How do you reset?
    By BillG in forum Queries
    Replies: 11
    Last Post: 09-13-2012, 04:41 PM
  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