Results 1 to 3 of 3
  1. #1
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    2,057
    Thanks
    164
    Thanked 194 Times in 187 Posts

    Access query date question

    I have a query that looks for dates older than 06/04/2017. So far so good. But to avoid changing the year each, I want the query to to have the date 06/04/yyyy where yyyy is the year the query is being run. I thought it would be easy, but it's not something I've needed to do and I can't see how to do it. It's a query that gets run once a year so we have to remember to change the year.
    What do you mean nothing is impossible? I've been doing nothing for years.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,971
    Thanks
    424
    Thanked 1,600 Times in 1,450 Posts
    Access,

    QryDte = "06/24/" & Trim(Str(Year(NOW())))

    Will give you a String value with the current year. If you want a Date Value then: dteQry = CDate(QryDte)

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    access-mdb (2018-04-12)

  4. #3
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    2,057
    Thanks
    164
    Thanked 194 Times in 187 Posts
    Brilliant! I had tried something like that but hadn't got trim and str bits in. Gives me just what I want. Ta muchly!
    What do you mean nothing is impossible? I've been doing nothing for years.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •