15 pts.
 Pulling previous years data based on dates entered in a from
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:
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
Last Wiki Answer Submitted:  April 27, 2010  3:55 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Can you post the SQL code of your query ?

 63,535 pts.

 

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 pts.