Solved Build A Query "Like Current Year" (1 Viewer)

pooldead

Registered User.
Local time
Yesterday, 20:23
Joined
Sep 4, 2019
Messages
136
Right off the top, I'd like to mention that I am trying to build this query in Query Design and not VBA, so that it can be used in a report chart.

I have a field with the date stored as yyyy-mm (2020-05). I'm trying to build a SELECT query that will pull data where the field has the current year. What I currently have is:
Code:
SELECT Field1
FROM Table1
WHERE Field1 Like "*(Year(Now()))*";
I don't get any errors with this, but the search pulls up empty. Can someone please assist?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:23
Joined
Oct 29, 2018
Messages
21,473
Hi. What is the data type of Field1?
 

pooldead

Registered User.
Local time
Yesterday, 20:23
Joined
Sep 4, 2019
Messages
136
Short text - but I tried with it as a number and Date/Time (formatted) as well and no luck
 
Last edited:

pooldead

Registered User.
Local time
Yesterday, 20:23
Joined
Sep 4, 2019
Messages
136
Yup, the literal value pulls the records.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:23
Joined
Oct 29, 2018
Messages
21,473
Yup, the literal value pulls the records.
So, that tells me there's something wrong with your expression to pull the current year. Try this one next:

WHERE Field1 Like "*" & Year(Date()) & "*"
 

Users who are viewing this thread

Top Bottom