Date Month, just stuck

Lister

Z Shift
Local time
Tomorrow, 06:02
Joined
Aug 24, 2003
Messages
305
Ok, I have had enough.
I have been haking on this query for three hours.
Let's see what the world has got. [dose it sound like I'm not happy or is it just me]
I have a Date/Time feild that I would like to use as the base of a query. (Field name [PaymentDate])
What I want is a "Criteria" that looks back over the last two months. So what ever the date is I would like it to look back at the last two months.
I have trided Between DateSerial(Year(Date(), Month(Date()-2,1) And DateSerial(Year(Date(), Month(Date(), 31)
Actually I have tried a lot, from DatePate to >Date()-60.
But I’m stumped.
Any help would be great.
Thanks
 
Sorry, mate.
All I got was a "Data Type Missmatch in Criteria expression" error with that.
I didn't try DateAdd, but tried all the others.
I also bumped into a new error I hadn't seen before.
Just called "Overrun"
No idea what that is.:confused:
 
In the dateadd() example, the interval and number are reversed. Try:

? dateadd("m", -2, date())
6/24/03

Your dateserial() attempts are missing needed closing parenthesis (in the Year() and Month() portions). Try:

? DateSerial(Year(Date()), Month(Date())-2,1)
6/1/03
 
Last edited:
Kick ass Raskew!

Thats the bugger!

Between DateSerial(Year(Date()),Month(Date())-2,1) And DateSerial(Year(Date()),Month(Date()),31)

I was so close and yet so far, thanks mate

:D
 
>
Between DateSerial(Year(Date()),Month(Date())-2,1) And DateSerial(Year(Date()),Month(Date()),31)
<

You are assuming there are 31 days in every month!
 
Just me being over enthusiastic. ;)
The final code that I used is

Between DateSerial(Year(Date()),Month(Date())-2,1) And DateSerial(Year(Date()),Month(Date()),0)

This works fine. As its August now it show all Invoices from the 1st of June to the 31st of July and nothing form August.
With any luck (and I can't see why not) when it clicks over to September, it will show all Incoices from 1st July to 31st August.
Thanks for all the help.
 

Users who are viewing this thread

Back
Top Bottom