Looking for formula confirmation

stapuff

Well-known Member
Joined
Feb 19, 2004
Messages
1,126
I wrote the following and it appears to be giving me the correct result, but.................

My criteria = I want to see all the results from (Current Month - 2) to Today. (5/1/2007 - Today)

Between DateSerial(Year(Now()),Month(Now())-2,1) And DateSerial(Year(Now()),Month(Now())+1,0)

Looking for someone to confirm or suggest.

Thanks,

Kurt
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,286
Office Version
  1. 365
Platform
  1. Windows
Kurt

You'd probably be better of using DateDiff and Today.

I don't quite understand how the second DateSerial would return today's date, if that's what it's supposed to do.
 

stapuff

Well-known Member
Joined
Feb 19, 2004
Messages
1,126
Norie -
You are correct. I posted
"My criteria = I want to see all the results from (Current Month - 2) to Today. (5/1/2007 - Today)"

When I should have posted
"My criteria = I want to see all the results for the previous 2 months through Today. (5/1/2007 - Today)"
 

NumbersMax

Board Regular
Joined
Jun 19, 2007
Messages
200
Many ways to skin a cat...

How about the Dateadd/DateSerial in conjuction?

Between
Dateadd("m", -2, DateSerial(Year(Now),Month(Now),1))
and
Now()

I added your expression to a query and it worked just fine the way it was. Mine also worked, but it's not like I put either through a lot of testing to see if there were any loopholes!

Max
 

Watch MrExcel Video

Forum statistics

Threads
1,130,311
Messages
5,641,453
Members
417,210
Latest member
rins

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top