Link to home
Start Free TrialLog in
Avatar of Cole100
Cole100Flag for United States of America

asked on

Need SQL code to query month to date last year

I am trying to build a query in Access 2010 to pull data from month to date last year.

Example. today being 10/29/14, I am using Between DateAdd("d",-DatePart("d",Date())+1,Date()) And Date()-1 which pulls my data for 10/1/2014 to 10/28/2014

I am trying to look a comparable sales data so I need a piece of code that pulls 10/1/2013 to 10/28/2013
Avatar of Haris Dulic
Haris Dulic
Flag of Austria image

Did you try this:

dateadd("y",-1,DateAdd("d",-DatePart("d",Date())+1,Date()) ) and dateadd("y",-1,Date()-1)
ASKER CERTIFIED SOLUTION
Avatar of Eric Sherman
Eric Sherman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cole100

ASKER

Both etsherman and gustav solution did exactly as i  needed. thank you