Pulling previous years data based on dates entered in a from

15 pts.
Tags:
Date calculation
I am working on an access db that is used to compare call volume for current year and previous year. I would like to enter the current year's dates on a from and write a query that will pull the previous year's data based on the dates entered. When using a Date -365 expression, the query shows last year's date however the data pulled is the current years data. Any suggesstions on how to get last years date along with last years data?

Software/Hardware used:
Access 2003
ASKED: April 27, 2010  2:17 PM
UPDATED: April 27, 2010  3:55 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try this:

<pre>SELECT [Date] AS Dates, [Data Table].Brand, [Data Table].[Calls Offered], [Data Table].[Calls Handled], [Data Table].[Voice Res], [Data Table].GDS, [Data Table].OTA, [Data Table].[OTA Net], [Data Table].Links, [Data Table].[Brand Web], [Data Table].Other
FROM [Data Table]
WHERE ([Date] Between [Forms]![frmMAIN]![WeekStartCY]-365 And [Forms]![frmMAIN]![WeekEndCY]-365)
ORDER BY [Data Table].Brand;</pre>

This is assuming that [Forms]![frmMAIN]![WeekStartCY] and [Forms]![frmMAIN]![WeekEndCY] are the start and end dates in the current year.

-CarlosDL

————-

testing this function

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Can you post the SQL code of your query ?
    65,110 pointsBadges:
    report
  • Zip13
    SELECT [Date]-365 AS Dates, [Data Table].Brand, [Data Table].[Calls Offered], [Data Table].[Calls Handled], [Data Table].[Voice Res], [Data Table].GDS, [Data Table].OTA, [Data Table].[OTA Net], [Data Table].Links, [Data Table].[Brand Web], [Data Table].Other FROM [Data Table] WHERE ((([Date]-365) Between [Forms]![frmMAIN]![WeekStartCY] And [Forms]![frmMAIN]![WeekEndCY])) ORDER BY [Data Table].Brand; I must add that I'm pretty new at building databases and SQL is still somehwat foreign to me
    15 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following