Extracting Next months data based on a date field

Hello experts,
I have a table holding a date field (Maintenance visits due).
I need to be able to run a report at any time in the current month that shows visits due next month.
So in December i need to see records for Jan etc etc.
My date field is "NextMaint" and I can a query that gives me the month for that 'Month: Format([nextmaint],"mm")' and the current month 'Currentdate: Format(Now(),"mm")'
However, I am a bit lost from there. Any help greatly appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
You can use DateADD to get the next month.

DateAdd("mm", 1, NextMaint)

Try like this..

Format(DateAdd("mm", 1, NextMaint),"mm")'
Bill PrewIT / Software Engineering ConsultantCommented:
You can select all records for next month with a query like below.  This selects all dates greater or equal to the first day of the next month, and less or equal to the last day.

FROM tblTest
WHERE (((tblTest.NextMaint)>=DateSerial(Year(DateAdd("m",1,Now())),Month(DateAdd("m",1,Now())),1)
AND (tblTest.NextMaint)<=DateSerial(Year(DateAdd("m",2,Now())),Month(DateAdd("m",2,Now())),1)-1));

Open in new window

Bill PrewIT / Software Engineering ConsultantCommented:
You can also do the following, although depending on data size and if the date field is indexed the prior may perform better.  But this one reads simpler :-).

FROM tblTest
WHERE Year(tblTest.NextMaint) = Year(DateAdd("m",1,Now())) 
AND Month(tblTest.NextMaint) = Month(DateAdd("m",1,Now()));

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Bill PrewIT / Software Engineering ConsultantCommented:
And probably a little safer for the boundary days in case they have time components...

FROM tblTest
WHERE tblTest.tstDate>=DateSerial(Year(DateAdd("m",1,Now)),Month(DateAdd("m",1,Now)),1) 
AND tblTest.tstDate<DateSerial(Year(DateAdd("m",2,Now)),Month(DateAdd("m",2,Now)),1);

Open in new window

Pawan KumarDatabase ExpertCommented:
You can use like below -

SELECT * FROM yourtableName

Open in new window

iainmacleodAuthor Commented:
Thank you both very much.
I went with Bills solution in the end, but great to have the knowledge of both.
What a great resource this site is...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.