user3280012
user3280012

Reputation: 41

MS Access Year(Date() Function

I'm trying to create a MS Access query to give me a count of records by month for the current year. The field with the date is text and the date is in the format of YYYY-MM. Everything I've read says to use Year(myDate) = 2014, but I don't get any results. I've also tried Year(Date()), but again no results. Any ideas on what to do to get this query to run?

Upvotes: 4

Views: 6125

Answers (1)

Gord Thompson
Gord Thompson

Reputation: 123549

One way to get "a count of records by month for the current year" would be

SELECT YearMonth, COUNT(*) AS RecordCount
FROM YourTable
WHERE YearMonth LIKE Year(Date()) & "*"
GROUP BY YearMonth

where [YearMonth] is your YYYY-MM text column.

Upvotes: 3

Related Questions