We help IT Professionals succeed at work.

Formula for last year

cansevin
cansevin asked
on
I am using the below code to pull up current year. How can I modify it so that it pulls up last year?

GROUP BY "ADAY", Format(Nz([qryFirstDayRevenueBooked].[FirstDay],#1/1/1950#),"yyyy")
HAVING (((Format(Nz([qryFirstDayRevenueBooked].[FirstDay],#1/1/1950#),"yyyy"))=Format(Now(),"yyyy")));
Comment
Watch Question

The part of your SQL statement that gives the current year is this:

    Format(Now(),"yyyy")

A better way to do this is:

    Year(Date())

To get last year, simply subtract 1:

    Year(Date()) - 1

Graham Mandeno [Access MVP since 1996]