Results 1 to 10 of 10
  1. #1
    Davism4 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2021
    Posts
    6

    Trying to return Week number starting from Monday in Report

    Hi

    I am out my depth with this, but my report is working with this line. The trouble is runs Sunday to Saturday. I would like to get the week day to start on Monday.



    How can I change this SQL line so it runs Monday to Sunday ??

    WHERE (((Year([Date Locked Out])*53+DatePart("ww",[Date Locked Out]))=Year(Date())*53+DatePart("ww",Date())-1))


    Thanks for your help,

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Have you tried including the "First Day of Week" argument?

    DatePart(interval, date, [ firstdayofweek, [ firstweekofyear ]])

    https://docs.microsoft.com/en-us/off...epart-function
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    Davism4 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2021
    Posts
    6
    I've been trying to incorporate it into the expression, but without luck so far !

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Sorry but your expression makes no sense to me.
    What is it your trying to do?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    As suggested:

    Code:
    WHERE (((Year([Date Locked Out])*53+DatePart("ww",[Date Locked Out],vbMonday))=Year(Date())*53+DatePart("ww",Date(),vbMonday)-1))
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    Davism4 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2021
    Posts
    6
    Thanks Vlad, I have tried this but I just end up with a pop up box for enter parameter value: vbMonday

    For a different angle , If I look at design view, it is :

    Year(Date())*53+DatePart("ww",Date())-1

    Any other ideas?

  7. #7
    Davism4 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2021
    Posts
    6
    Hi, I am simply trying to produce a report of the previous weeks data, running Monday - Sunday.
    My code is working but it is running Sunday - Saturday !

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Try using the actual value (2) instead of the built in constant name:
    Code:
    WHERE (((Year([Date Locked Out])*53+DatePart("ww",[Date Locked Out],2))=Year(Date())*53+DatePart("ww",Date(),2)-1))
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    Davism4 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2021
    Posts
    6
    Vlad, that works! Brilliant thank you so much

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    You're very welcome!
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Group By Week Starting Monday?
    By kestefon in forum Access
    Replies: 1
    Last Post: 02-06-2014, 06:33 PM
  2. Parameter Value = Monday of the current week VBA
    By bcn1988 in forum Programming
    Replies: 4
    Last Post: 09-13-2013, 10:35 AM
  3. 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
  4. Replies: 5
    Last Post: 09-20-2012, 11:34 AM
  5. Replies: 1
    Last Post: 07-27-2010, 09:47 AM

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