Print Page | Close Window

a month number must be between 1 and 12

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Announcements
Forum Discription: Please check this section for the latest announcements from Crystal Reports Forum
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=18902
Printed Date: 01 May 2024 at 8:11pm


Topic: a month number must be between 1 and 12
Posted By: kevinp70
Subject: a month number must be between 1 and 12
Date Posted: 25 Jan 2013 at 10:23am
Hello... I have a "monthly" report that works perfectly when ran; however, it will not run for the month of December of any year. I get the error " month number must be between 1 and 12".. the formula editor then opens with the code. Any suggestions why only for Dec of any year it fails with this message? Thank You!

{u_case.cs_date_filed} in (Date (Year({u_case.cs_date_filed}), Month({u_case.cs_date_filed})+1, 1) -4) to (Date(Year({u_case.cs_date_filed}), Month({u_case.cs_date_filed})+1 , 1) -1)



Replies:
Posted By: hilfy
Date Posted: 28 Jan 2013 at 6:04am
That's because the month for December is 12 and you're adding 1 to it to make 13, which is not a valid month.
 
Try something like this:
(
(Month({ucase.cs_date_filed}) < 12 and 
 {u_case.cs_date_filed} in 
 (Date (Year({u_case.cs_date_filed}), Month({u_case.cs_date_filed})+1, 1) -4) to 
 (Date(Year({u_case.cs_date_filed}), Month({u_case.cs_date_filed})+1 , 1) -1)
OR
(Month({ucase.cs_date_filed) = 12 and
 {ucase.cs_date_filed) in
 (Date (Year({ucase.cs_date_filed}) + 1, 1, 1) - 4) to
 (Date(Year({ucase.cs_date_filed}) + 1, 1, 1) - 1))
)
 
Note where I've put the red parentheses - those are required in order for this to work correctly.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: kevinp70
Date Posted: 28 Jan 2013 at 11:29am
Genius my friend... thank you !



Print Page | Close Window