DateSerial

G

Guest

Hi guys

I've got a query that uses this formula in the criteria of the field "Delays".
DateSerial(Year(Date()),IIf(Month(Date())=1,12,Month(Date())-12),"00"
This is supposed to pick all the records whose "delays" date is from a year ago to date
It used to work fine but since I went to the year 2004, it displays nothing
Any idea?
 
R

Rick Brandt

Cristo said:
Hi guys,

I've got a query that uses this formula in the criteria of the field "Delays".:
This is supposed to pick all the records whose "delays" date is from a year ago to date.
It used to work fine but since I went to the year 2004, it displays nothing.
Any idea?

The final argument should be a number, not a string (no quotes). But I
don't see it producing what you're describing anyway. For today it returns
11/30/2004 because it evaluates to DateSerial(2004, 12, 0).

If you just want the date from a year ago it should be...

DateSerial(Year(Date())-1, Month(Date()), Day(Date()))

...which returns 1/7/2003.

You could also use...

DateAdd("yyyy", -1, Date())
 

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