Results 1 to 4 of 4
  1. #1
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410

    Year Date Change?

    I am currently using Year(Date()-1) and Year(Date()) for current year to prior year comparison.



    However when the new year came the Dec. comparison is lost due to the Year(Date()-1) and Year(Date()).

    I'm not sure how to change it so that Jan of the current is still looking at the prior year from last year and prior year as the Year(Date()-1) and Year(Date()).

    Hope this made sense.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,948
    Could have an expression: Year(Date()) - IIf(Month(Date()) = 1, 1, 0)

    Really, best way to handle is to have parameter input. This can be a popup from query (I never do popups) or reference to a control on form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    You also have to think about Feb. 29th. That date wouldn't work in your query either, since there will never be a Feb. 29th for the previous year.

    Probably the best way would be to simply compare the current date with the date 365 days ago instead of 1 year ago.

    Code:
    DateAdd("d", -365, Date()) ' Use days instead of years to prevent dates around the beginning/end of each month from behaving strangely

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,948
    I just noticed the expression in OP is subtracting 1 day from the date. That won't return previous year. Did you mean: Year(Date())-1 and Year(Date())
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-25-2014, 11:33 PM
  2. Change The Year End Date
    By VariableZ in forum Programming
    Replies: 1
    Last Post: 05-24-2013, 08:32 AM
  3. Replies: 4
    Last Post: 01-09-2013, 11:16 AM
  4. Replies: 4
    Last Post: 01-10-2012, 06:26 PM
  5. How to change year digit in update query?
    By Osman in forum Queries
    Replies: 6
    Last Post: 10-27-2010, 04:35 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