Access date formula syntax

I'm looking for a formula that gives a date range of >7th last month and less than 7th this month

e.g. >07/03/2015 and <=07/04/2015. I would always want the day range to be from the 7th of this month to the 7th of last month regardless of the day it is run.

Data type is 'Date/Time' (UK Date), can anyone help?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
use this as the criteria

between dateserial(year(date()),month(date()),7) and dateserial(year(date()),month(date())-1,7)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try this:

BETWEEN dateserial(year(date), Month(date), 7)  AND dateserial(year(date), Month(date) + 1, 7)

Open in new window

Whoops - I misread that as between 7 of this month and 7 of NEXT month, so this is not quite what you want.
Rey Obrero (Capricorn1)Commented:
to include date with time values, try

between dateserial(year(date()),month(date()),8) and dateserial(year(date()),month(date())-1,8)
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

HKFueyAuthor Commented:
V. quick thanks, I tried both but get no records, here is the SQL:

WHERE InvoiceDate Between DateSerial(Year(Date()),Month(Date()),7) And DateSerial(Year(Date()),Month(Date())+1,7)

Date example: 28/01/2015
HKFueyAuthor Commented:
DateFrom = DateSerial(Year(Date), Month(Date) - 1, 8)
Datefrom comes out as 03/08/2015 (3rd August)
Try this:

WHERE InvoiceDate  BETWEEN dateserial(year(date), Month(date) -1 , 7)  AND dateserial(year(date), Month(date))

Open in new window

or this:

WHERE Format(InvoiceDate, 'yyyymmdd') BETWEEN format(dateserial(year(date), Month(date) -1 , 7), 'yyyymmdd') AND format(dateserial(year(date), Month(date)), 'yyyymmdd')

Open in new window

Gustav BrockCIOCommented:
>  date range of >7th last month and less than 7th this month

Then this is correct:

    Between DateSerial(Year(Date()),Month(Date())-1,8) And DateSerial(Year(Date()),Month(Date()),6)

> Date example: 28/01/2015

That will, of course, be excluded. You will only see records from 2015-03-08 to 2015-04-06 inclusive.

> DateFrom = DateSerial(Year(Date), Month(Date) - 1, 8)
> Datefrom comes out as 03/08/2015 (3rd August)

No, it is just the format, mm/dd/yyyy. The value is 2015-03-08.

HKFueyAuthor Commented:
Thanks all for the help, sorry for delay been on holiday!
This worked for me: -
Dim DateFrom
Dim DateTo
DateFrom = Format(DateSerial(Year(Date), Month(Date) - 1, 7), "yyyy/mm/dd")
DateTo = Format(DateSerial(Year(Date), Month(Date), 7), "yyyy/mm/dd")

WHERE InvoiceDate Between #" & DateFrom & "# And #" & DateTo & "#
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.