Current Year

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

May query needs to return current Year only.
I have a seperate column for the Year.
Is there a code to say: ((InvClosed.Year)=CURRENT))


Thanks
 
Assuming that you used a 4 character year, put InvClosed.Year in the column
heading of a query .

In the criteria put:
Year(Now())
 
I think I can help... Open your query in design view. Right click on
heading of the date field you want to sort by and select "properties".
Specify the format to be "yyyy". Then, in your criteria, specify Like
"*2007*" and run the query. I know you want to use a function like Date() to
avoid having to update the query every year, but I don't know of a way to do
that. Perhaps someone else? In any case, this will work until you find a
better way.
 
May query needs to return current Year only.
I have a seperate column for the Year.
Is there a code to say: ((InvClosed.Year)=CURRENT))


Thanks

If you have both a date field and a year field with the same year, that's not
very good design: what if the InvClosed date contained #12/30/2006# and the
[Year] field contained 2007? One would be wrong, and there'd be no obvious
indicator that you're getting the wrong year's data!

That said: Year is a reserved word, for the builtin Year() function, and
*will* cause trouble. You can try

((InvClosed.[Year]) = Year(Date()))

to get the current year. If you have an InvDate field you can avoid the
redundancy and still take advantage of an index on InvDate by deleting the
Year field from your table altogether and using a criterion

[InvDate] >= DateSerial(Year(Date()), 1, 1) AND [InvDate] <
DateSerial(Year(Date)) + 1, 1, 1)

John W. Vinson [MVP]
 
Back
Top