Question Regarding DateSerial

GMFTM

New Member
Joined
Nov 4, 2016
Messages
42
I have an expression:

Sum(IIf([Sale_Date] Between DateSerial(Year(Now()),Month(Now())-1,1) And DateSerial(Year(Now()),Month(Now())-1,Day(Now()))-1,1,0))

Now I need to make sure that when it hits 1/2018 that this will grab 12/17

How do I modify this to make that work?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Application.EDate(DateSerial(Year(Now()), Month(Now()), 1), -1)

or

Application.EoMonth(Now(), -2) + 1
 
Last edited:
Upvote 0
That's seems like what you have already.

Sample code:
Code:
Sub foo()

Dim d(3) As Date

d(0) = #1/18/2018#
d(1) = DateSerial(Year(d(0)), Month(d(0)) - 1, 1)
d(2) = DateSerial(Year(d(0)), Month(d(0)) - 1, Day(d(0))) - 1

Debug.Print d(1)
Debug.Print d(2)

End Sub

Result:

12/1/2017
12/17/2017
 
Last edited:
Upvote 0
The whole thing :

Code:
With Application
  Sum(IIf([Sale_Date] Between .EoMonth(Now(), -2) + 1 And .EDate(now(),-1)-1,1,0))
End With
 
Upvote 0

Forum statistics

Threads
1,221,531
Messages
6,160,357
Members
451,642
Latest member
mirofa

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
Back
Top