View Full Version : DMax and DateDiff func


AlLeX_Brd
07-13-2005, 12:10 PM
HI All,

I'm using
Between DMax("DateFieldName","TableName")-10 And DMax("DateFieldName","TableName") expression

in query to find time interval 10 days prior the last record puting this into Date field in my query Criteria. It's working fine.
But I want to find time interval a Month and an Year prior the last record.
I'm thinking to use DateDiff func to calculate properly intervals.

Between DMax("DateFieladName","TableName")-DateDiff ("m",1-2-100,1-1-100) And DMax("DateFieldName","TableName") --> for a month

That function also work but I'm not sure if it calculate correct result

Any better ideas? Thanks!

:cool:

mresann
07-13-2005, 01:53 PM
Take a look at the DateSerial function.

ScottGem
07-13-2005, 04:32 PM
HI All,

I'm using
Between DMax("DateFieldName","TableName")-10 And DMax("DateFieldName","TableName") expression

in query to find time interval 10 days prior the last record puting this into Date field in my query Criteria. It's working fine.
But I want to find time interval a Month and an Year prior the last record.
I'm thinking to use DateDiff func to calculate properly intervals.

Between DMax("DateFieladName","TableName")-DateDiff ("m",1-2-100,1-1-100) And DMax("DateFieldName","TableName") --> for a month

That function also work but I'm not sure if it calculate correct result

Any better ideas? Thanks!

:cool:

What you need is something like this:

BETWEEN DateAdd("m",-1, DMax("DateFieldName","TableName")) AND DMax("DateFieldName","TableName")

That will give records between the last Date and one month prior.

AlLeX_Brd
07-14-2005, 09:32 AM
Thanks! I'll try it