Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2020
    Posts
    2

    Last Year Month to Date Query


    I'm getting my this years month to date with


    Between [Forms]![Westwood Night Audit]![Start Date] And [Forms]![Westwood Night Audit]![CHQ#_Date].


    How can I use the same to get Last Years Month to Date?
    Example: today is 17Dec20 and my month to date is 1Dec20 to 17Dec20. Now I also need a the same column but with last years month to date.

    I know it should be easy but I just can't get it to work. Hopefully someone can get it to work.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Use DateDiff() and subtract a year?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    yes, datediff("yyyy",-1,Date())

    put some controls on your form to help fill the start/end date. Month-to-date, month, week,etc...
    then just click the 'range' to fill in the date boxes.
    Attached Thumbnails Attached Thumbnails date set.png  

  4. #4
    Join Date
    Dec 2020
    Posts
    2
    Thanks for the quick response that was what I was looking for. Now it works.

  5. #5
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Be aware that object names (field, table, form, report, query, module) should only be letters and numbers, exception is the underscore(_).
    Should NOT use spaces, special characters or punctuation.
    Should not begin an object name with a number


    Example:
    Bad
    Code:
    Between [Forms]![Westwood Night Audit]![Start Date] And [Forms]![Westwood Night Audit]![CHQ#_Date].
    Has spaces and the hash mark (# - the Date delimiter)
    Better
    Code:
    Between [Forms]![WestwoodNightAudit]![StartDate] And [Forms]![WestwoodNightAudit]![CHQ_Date].
    No spaces, no special characters...



    And Welcome to the forum....

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

Similar Threads

  1. Replies: 4
    Last Post: 05-03-2017, 09:48 AM
  2. Count by Date, Month and Year in one Query
    By Medee in forum Queries
    Replies: 1
    Last Post: 06-25-2016, 03:48 AM
  3. Replies: 5
    Last Post: 08-14-2015, 02:53 PM
  4. Replies: 5
    Last Post: 08-26-2014, 06:07 AM
  5. Replies: 4
    Last Post: 05-26-2013, 03:28 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