Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rolling 13month query?

Status
Not open for further replies.

DougJ

Technical User
Mar 26, 2003
2
AU
Hi all, been beating my head against the wall with this one....I need to create a rolling 13 month query based on an ever expanding (month by month table)

For example my query returns the following results but but I am only interested in the last 13 months...any ideas?

Month
May-2001
Jun-2001
Jul-2001
Aug-2001
Sep-2001
Oct-2001
Nov-2001
Dec-2001
Jan-2002
Feb-2002
Mar-2002
Apr-2002
May-2002
Jun-2002
Jul-2002
Aug-2002
Sep-2002
Oct-2002
Nov-2002
Dec-2002
Jan-2003
Feb-2003
Mar-2003

Cheers
Doug.
 
I haven't time to do the whole lot for you but you need to include a phrase something like:
Between Now()-395 And Now()

I chose 395 because it's 13/12 *365, but you will probably want to get the end of the current month from Now() and the beginning of the month a year and a month ago. As a hint, to get the last day of a month find the first day of the next month and remove a day!

Simon Rouse
 
or
Code:
Public Function bas13Months(dtIn As Date) As Date

    Dim LastOfMnth As Date
    LastOfMnth = DateSerial(Year(dtIn), Month(dtIn), 1)

    bas13Months = DateAdd("m", -13, LastOfMnth)

End Function


MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Thanks for your help gents. Will give it a try asap. Wish me luck....

Cheers
Doug.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top