Avatar of billg7
billg7
Flag for United States of America asked on

Access 2010 SQL Query - Looking up last month's data

Greetings Experts!

I am trying to create a query that looks up dates only from last month. You'll laugh, but here's the where clause I had and it worked:

WHERE (((DatePart("m",[Work week],0))=DatePart("m",Date(),0)-1));

UNTIL January :). I also realized that i wasn't checking the year...

I looked around online, and one answer was to use

DATEDIFF(m,[Work Week],date())=1

But that threw an invalid procedure call error.

All of the other stuff I saw was just wrong like my first attempt :)

As always, your help is greatly appreciated.

Thanks!
Microsoft Access

Avatar of undefined
Last Comment
Rey Obrero (Capricorn1)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jerryb30

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
billg7

ASKER
Beautifully simple. Love it! Thank you!
Rey Obrero (Capricorn1)

use a where clause like this

where [work Week] between dateserial(Year(now()),Month(now())-1,1) and dateserial(Year(now()),Month(now()),0)


dateserial(Year(now()),Month(now())-1,1) will give you  12/1/2012

dateserial(Year(now()),Month(now()),0) will give you  12/31/2012
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy