Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rohitraturi
Contributor II
Contributor II

Calculating number of days

I want to calculate the number of days for three months (current month and previous two months) when I select the current month.

Example: If I select Dec then I should get days from Dec, Nov, and Oct i.e. 92 days.

I am using the following code but it works only when I select Oct and Dec.

Floor(MonthEnd(Max([Posting Date])))- Floor(MonthStart(Min([Posting Date])))+ 1

2 Replies
seanbruton
Luminary Alumni
Luminary Alumni

Hi There,

 

I have a similar code running which is below, the trick is to do the calculation and bracket it then add the 1 day afterward.

 

(
Floor(MonthEnd(Max(if(CYTD_Ind = 1,[CalcDate]))))
-
AddMonths(monthstart(min(Floor(if(CYTD_Ind = 1,[CalcDate])))),1)
)+1

 

in your case:

(
Floor(MonthEnd(Max([Posting Date])))
-
AddMonths(monthstart(min(Floor([Posting Date]))),1)
)+1

 

Regards, Good Luck!

 

 

Anil_Babu_Samineni

Perhaps this?

Count({<DateField = {">=$(=Date(MonthStart(AddMonths(Max(Month), -3)),'Your Date Format Here'))<=$(=Date(MonthEnd(Max(Month)),'Your Date Format Here'))"}>} DateField)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful