Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

1 year from today query

Status
Not open for further replies.

SSGClark

Technical User
Aug 19, 2000
33
0
0
US
I have a simple database that we use to track dates of several misc items. I am trying to create a simple query that we can run that will tell us when an item is over 1 year from &quot;today&quot; without having to type in query i.e Last_Inventory_Date <02/14/2002

I have a different query that tracks by month/year of current that is: Year([Last_Inspection_Date])=Year(Now()) And Month([Last_Inspection_Date])=Month(Now()) I need to know how to make it so it checks all records that is 1 year over from todays date.

Thanks

Thanks,

Mike
ledzep@hot.rr.com
 
You can use dateadd to return a date a fixed time away from now.

eg. DateAdd(&quot;yyyy&quot;, -1, Date)
returns the date one year ago.

So you could use something like.

Last_Inventory_Date < DateAdd(&quot;yyyy&quot;, -1, Date)

There are two ways to write error-free programs; only the third one works.
 
Thanks GHolden, I tried your method and it gave me errors which I couldn't find a fix for. So I tried a mix of things and the one that worked is - Year([Last_Inventory_Date])=Year(Now())-1 And Month([Last_Inventory_Date])=Month(Now())
So far it's working.. let's see how it does next month =) Thanks,

Mike
ledzep@hot.rr.com
 
Glad you got it sorted may have been missing brackets in the date...

Last_Inventory_Date < DateAdd(&quot;yyyy&quot;, -1, Date)

should be

Last_Inventory_Date < DateAdd(&quot;yyyy&quot;, -1, Date())

There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top