Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula to display month range is not working 1

Status
Not open for further replies.

travelerII

Technical User
Jun 4, 2009
66
US
I am working with Crystal 10 and need to see the orders for the current month and then rolling forward I need to see one month out, then two months out, then months 3-12 months out.
I wrote the following formulas to identify the columns.

MonthName(Month (CurrentDate)) for current month

MonthName(Month (CurrentDate)+1) for 1 month out

MonthName(Month (CurrentDate)+2) for 2 months out

MonthName(Month (CurrentDate)+3)+ " thru " + MonthName(Month (CurrentDate)-1) for the range of 3 months out thru 12 months out.

This has been working fine but now that we are in October it is returning an error because it says a month number must be between 1 and 12 and obviously in my last formula the 10th month plus 3 is 13. I assume the other formulas will have the same problem as we approach the end of the year.
Any ideas on how I can solve this problem?

Thank you for the help.
 
monthname(month(dateadd("m",3,currentdate)))

-LB
 
Thank you for your quick response. I am a little confused though.

Is this formula to replace the first part of my range formula
MonthName(Month (CurrentDate)+3)?

If so then for the second part of the range MonthName(Month (CurrentDate)-1) do I use the formula

monthname(month(dateadd("m",12,currentdate)))?
 
Not sure what the -1 is about here. For 12 months out, you would just use 12 instead of 3 in the dateadd formula:

MonthName(Month (dateadd("m",3,currentdate)))+ " thru " +
MonthName(Month (dateadd("m",12,currentdate)))

You can use -1 for the previous month, for example.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top