Date Restrictor for Last Month

C

ChuckW

Hi,

I want to create a date restrictor for last month's sales that will roll
each month. So if I run it today it will give me April sales and if I run it
on June 1st, it will give me May sales.

Thanks,
 
M

Martin J

Between dateserial(year(date()),month(date())-1,1) and
dateserial(year(date()),month(date()),1)-1
 
C

ChuckW

Martin,

Thanks for your help. I also want to get a rolling date restrictor for the
same thing but a year ago. So if I ran it today, it would give me April 2004
sales and if I ran it on June 1st, it would give me May 2004 sales. Can you
help?

Thanks,
 
M

Martin J

Between dateserial(year(date())-1,month(date())-1,1) and
dateserial(year(date())-1,month(date()),1)-1
 
R

Rick Brandt

Martin said:
Between dateserial(year(date())-1,month(date())-1,1) and
dateserial(year(date())-1,month(date()),1)-1

You don't actually need the minus 1 on the end. Just use zero for the final
argument instead of 1.

Between dateserial(year(date())-1,month(date())-1,1) and
dateserial(year(date())-1,month(date()),0)
 
M

Martin J

Your right about the 0 being easier to write. But I doubt any beginner who
asks this type question will understand why the 0 will work. By doing -1 I
just might save a question 2 or 3 months from now when he wants to make a
change. Or tries to use the same idea at the end of the month.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top