Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    658

    Once again, how replace dates?

    This has driven me nuts before. I've spent about an hour trying to just add a year to certain dates in both the table and a query.



    This error makes no sense to me, it should be simple enough. This is what I see after pressing Replace.

    Click image for larger version. 

Name:	Screenshot 2024-03-05 184347.png 
Views:	30 
Size:	83.6 KB 
ID:	51569

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm not sure you can do it that way, though I've never tried. I'd use the DateAdd() function to add a year to any date in 2023 with an update query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    It works for me on a table. I suspect you have a non-editable query.
    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.

  4. #4
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    658
    @ June7 #3 I can't seem to get it to work, same error over and over no matter what I try in the table or query. The query I just created from scratch, so nothing weird.
    Access 2021

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Guess you will have to provide your db for analysis.
    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.

  6. #6
    Join Date
    Apr 2017
    Posts
    1,680
    Dates in query result being aligned to right indicates, that those are not datestrings, but real dates. This means, that you are trying to replace in number 45199 (what is the numeric value of date 30/09/2023) the part of this number '2023' with '2024'! I'm not sure this will work at all!

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    As stated in post #3, works for me.
    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.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Works for me on a table as well.
    However when I do it, it shows the name of the field, not Current Field?
    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

  9. #9
    Join Date
    Apr 2017
    Posts
    1,680
    Quote Originally Posted by June7 View Post
    As stated in post #3, works for me.
    Maybe! I don't see any reason even to try it out! Why doesn't OP simply run an update guery for table, and replace dates from year 2023 with ones from year 2024 (the same way pbaldy adviced in post#2)? Following the picture in post#1, all dates from year 2023 must be replaced anyway.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I have no idea why they choose this approach, just saying it worked in my test.
    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.

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Quote Originally Posted by June7 View Post
    I suspect you have a non-editable query.
    If its a read only query, you cannot select Replace.

    Whilst I would also use an update query, the approach shown in #1 should work
    Just a guess - perhaps the date field has a validation rule that blocks future dates?
    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

  12. #12
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    post deleted - wrong search term (too early in the morning, need a coffee)
    Last edited by CJ_London; 03-06-2024 at 04:24 AM. Reason: wrong search term

  13. #13
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    658
    @ various I think I figured out the problem.
    It seems if there is formatting in a date in the table definition, Access can't handle that.
    I like to display dates in the ISO format:
    Click image for larger version. 

Name:	20240306Date2.png 
Views:	20 
Size:	9.0 KB 
ID:	51573

    Removing the format, making the change in the table with Replace worked.
    Then I added the formatting back. Interesting.

  14. #14
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Not being picky, but... The example you posted up in #1 didn't have that format, so we wouldn't have tried that or suspected a formatting issue as it appeared unformatted?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  15. #15
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    658
    @Minty, #14 As I said in the OP, it was an hour of trying different things in the table and queries (trying different formats in properties). I'm sure you didn't want a screen shot of every test. Turns out whatever format it is or whether it's done in a table, or query, it just doesn't work with special formatting in the table. As best as I've been able to figure out. If you null out the format, I wonder what Acces is using for the format, since the date isn't showing as a double.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 21
    Last Post: 06-23-2020, 11:45 AM
  2. Replies: 13
    Last Post: 03-22-2019, 04:09 PM
  3. Replies: 2
    Last Post: 09-19-2017, 11:31 AM
  4. Replies: 8
    Last Post: 12-02-2013, 03:46 PM
  5. Replies: 3
    Last Post: 06-07-2012, 07:05 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