Calendar Date

J

Joe

I need to put criteria in a query for Hire Date. I need it to be
between the first of the year and the current date. I know i can use
the current date as Date(), however I want the first of the year to
NOT be >12/31/2009 and instead be dynamic enough to know when a new
year starts. Ideas?
 
J

John W. Vinson

I need to put criteria in a query for Hire Date. I need it to be
between the first of the year and the current date. I know i can use
the current date as Date(), however I want the first of the year to
NOT be >12/31/2009 and instead be dynamic enough to know when a new
year starts. Ideas?
Try

= DateSerial(Year(Date()), 1, 1) AND <= Date()

The DateSerial function takes three number arguments, year, month, and day, so
this expression will search from the start of this year (whenever it's run)
and today.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
D

David W. Fenton

The DateSerial function takes three number arguments, year, month,
and day, so this expression will search from the start of this
year (whenever it's run) and today.

You're assuming the field being searched has no time component (a
reasonable assumption), but many people erroneously populate date
fields (like Hire Date) with Now() instead of Date(), so to account
for that, the <= Date() might be replaced with <= Now().
 
J

John W. Vinson

You're assuming the field being searched has no time component (a
reasonable assumption), but many people erroneously populate date
fields (like Hire Date) with Now() instead of Date(), so to account
for that, the <= Date() might be replaced with <= Now().

Or even

< DateAdd("d", 1, Date())
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

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