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?
HKFueyAsked:
Who is Participating?
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)
0

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
mbizupCommented:
Try this:

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

Open in new window


EDIT -
Whoops - I misread that as between 7 of this month and 7 of NEXT month, so this is not quite what you want.
0
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)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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
0
HKFueyAuthor Commented:
DateFrom = DateSerial(Year(Date), Month(Date) - 1, 8)
Datefrom comes out as 03/08/2015 (3rd August)
0
mbizupCommented:
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

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

/gustav
0
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 & "#
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.