Solved

"A month number must be between 1 and 12" error in formula

Posted on 2008-10-27
5
2,128 Views
Last Modified: 2012-05-05
I've created a report that will run for the last twelve months based on the current date (a rolling 12 month report).

I'd like to make some corresponding labels for the month values.  I was using this:
monthname (Month (CurrentDate), True)
monthname (Month (CurrentDate) - 1, True)
etc.

and it was working great until I got to month - 10.  Then I got this error:

A month number must be between 1 and 12


Any ideas?  Is there another way to accomplish my goal?  Also, I have to keep the labels short for space consideration which is why I need "Oct" instead of "October".

Thanks in advance,

Steve
0
Comment
Question by:SStroz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 400 total points
ID: 22810718
for previous months..
monthname (Month (dateadd("m",-1, CurrentDate) , True)
monthname (Month (dateadd("m",-2, CurrentDate) , True)
etc
0
 
LVL 16

Expert Comment

by:wykabryan
ID: 22812870
Peter is correct.

The problem that you are running into with taking a month minus 1 is that month is a number not a date, so 1-1 = 0 but Crystal then tries to reapply date functionality to it and errors cause there is no 0 month. I stress this to all of my developers, anytime you are doing a date modification use the dateadd function. It will prevent many issues down the road.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 22819129
I agree.  Good explanation.

It also solves the year issue.

mlmcc
0
 
LVL 7

Author Comment

by:SStroz
ID: 22819212
peter57r,

When I try:
monthname (Month (dateadd("m",-10, CurrentDate) , True)

I get an error that "the ) is missing".  If I add a ")" at the end of the statement I get an error that Too many arguments have been given to this function.

What am I missing?

Steve
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 100 total points
ID: 22819269
Put it after CurrentDate

monthname (Month (dateadd("m",-10, CurrentDate) ), True)

mlmcc
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question