Today's date (minus) 1 year?

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

Guest

Please help me to know how to write an expression for a criterion which will
pull only records with a date over the past calendar year counting back from
now()
 
Sorry but
1. "y" is day of the year which is 1-365/366 NOT the year itself.
2. Now() includes time as well as date and should be avoided in this type of
expression since it will give unexpected results. If you subtract 1 year
from 11/29/05 12:14 you get 11/29/04 12:14 AM. If you then use an
expression that compares that date you will find that 11/29/04 12:14 is
GREATER than 11/29/04 00:00 which may not be what you anticipated.
 
I'm afraid that didn't work - when I ran the query, it came up empty.
The name of the field I'm trying to pull out the prior year's date from is
"D1Tx". Do I need to enter that in the expression somehow to make it work?
I'm new to writing expressions & using SQL... not even sure when to use
which. Do you have a resource to recommend?
Again, thanks!
 
I'm afraid that didn't work - when I ran the query, it came up empty.
The name of the field I'm trying to pull out the prior year's date from is
"D1Tx". Do I need to enter that in the expression somehow to make it work?
I'm new to writing expressions & using SQL... not even sure when to use
which. Do you have a resource to recommend?
Again, thanks!
 
I'm afraid that didn't work - when I ran the query, it came up empty.
The name of the field I'm trying to pull out the prior year's date from is
"D1Tx". Do I need to enter that in the expression somehow to make it work?
I'm new to writing expressions & using SQL... not even sure when to use
which. Do you have a resource to recommend?
Again, thanks!
 
NC_Sue said:
I'm afraid that didn't work - when I ran the query, it came up empty.
The name of the field I'm trying to pull out the prior year's date from is
"D1Tx". Do I need to enter that in the expression somehow to make it work?
I'm new to writing expressions & using SQL... not even sure when to use
which. Do you have a resource to recommend?
Again, thanks!

Did you put the (implied) Greater Than operator in front of the expression Allen
gave you? Your criteria underneath your D1Tx field should be...
 
If you want the entire prior year, then try the following.

Field: D1Tx
Criteria: Between DateDiff("yyyy",-1,Date()) and Date()

For today (11-30-2005) that should find all records between 11-30-2004 and
11-30-2005. If you need some dates slightly different than that post back
with an explanation. The simplest explanation would be a sample that said -
given this date I want records between these two dates.
 
I would have SWORN I'd copied/pasted precisely, but I can now get it to work
doing just what you said - thanks a lot.
Also, can you give me a decent reference to get me off the ground in terms
of writing expressions & learning SQL?
 
Back
Top