Any date Last Year

T

Tara

I need to create a query that will return any date from the previous calendar
year. So, if I were to run the query today, it would return all records that
had any date in 2007. If I were to run it next year, it would return all
records that had any date in 2008.

Any help is appreciated!
 
R

Rick Brandt

mscertified said:
WHERE DatePart('yyyy',FieldDate) = DatePart('yyyy',Date())-1

-Dorian

One should never apply criteria to an expression unless you absolutely have to.
Much more efficient (if FieldDate is indexed) would be...

WHERE FieldDate >= DateSerial(Year(Date())-1, 1, 1)
AND FieldDate < DateSerial(Year(Date()), 1,1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top