5 Replies Latest reply on Jul 1, 2015 9:02 PM by davidhead

# How to List months between 2 Dates ?

Employees have Monthly Reports .

Some Employees may  submit reports for mulltiple months   i.e  date range  ( start Date )    and( End Date)

Can I get the List of Months beween the 2 dates  ?

e.g. 1

start date (  1st Jan  2015 )

end date  ( 31st March 2015 )

DESIRED RESULT   =     "January , February , March"      OR    " Jan  -  Mar  "

e.g. 2

start date (  1st Dec  2015 )

end date  ( 31st May 2016 )

DESIRED RESULT   =     "December , February , March"      OR    " Dec  -  May  "

• ###### 1. Re: How to List months between 2 Dates ?

I think the first option (month names as a comma separated list) would be best done as a recursive custom function:

MonthList ( datestart ; dateend ) =

Let ([

sm = Month ( datestart );

em = Month ( dateend );

em = em + If ( em < sm; 12 )

];

If ( sm ≠ em;

MonthName ( datestart ) & ", " & MonthList ( Date ( sm+1; 1; Year ( datestart ) ) ; dateend ) ;

MonthName ( datestart )

)

)

The second option is easier as a standard calculation:

Left ( MonthName ( start date ); 3 ) &

If ( Month ( start date ) ≠ Month ( end date ) ; " - " & Left ( MonthName ( end date ); 3) ; "" )

Hope that helps.

• ###### 2. Re: How to List months between 2 Dates ?

Thanks David ... Will try it out