Full Version: Puzzler. get the last 12 months from end date month.
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
plocke
SELECT
FROM tblEvents where ((([tblEvents].[Date])>=[txtEndDate] And ([tbEvents].[Date])<=[txtEndDate]))

I have a date range specified on a report with sub reports.. the user enters start and end date,
for example.

06/26/05 to 10/25/05

one subreport returns values for this range just fine..

but on the second I want to return the last full 12 months up to the specified end month... if the end month was 10/25/05 I want the start date the query to be 12 months behind the month and year of the end date

11/01/04 to 10/25/05


how can i convert.. 06/26/05 to 11/01/04 ?
???

Anyone brave enough? = ) *dangles raw meat from a stick*
NoahP
Try:

DateSerial(Year(txtEndDate),Month(txtenddate)-11,0)

As an aside, 'Date' is a Reserved Word and should never be used as the name of a field or control. Using any Reserved Word can cause mysterious errors that are very hard to diagnose.

Just curious, is txtEndDate a parameter or how are you entering it? (I don't see a reference to the form is why I ask.)

HTH
Noah

PS - keep the meat!
plocke
what am i gonna do with all this meat?

yea.. ultimately this query refrences report text box parameters..

thanks a lot!

oh.. and the date thing.. i know, vendor database im pulling from.. what a pain.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.