Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Formula error or data error? Post Reply Post New Topic
Author Message
thummel1
Senior Member
Senior Member
Avatar

Joined: 27 Apr 2012
Location: United States
Online Status: Offline
Posts: 140
Quote thummel1 Replybullet Topic: Formula error or data error?
     Posted: 31 Jan 2013 at 6:51am
I have a Crystal 2008 report that has been working just fine until recently. When I refresh the report I get this error message:
"A day number must be between 1 and the number of days in the month."
This error points me to this formula:
(the part in italics is highlighted)
 
My "@AsofDate" formulas refer to a date parameter. The type is "Date", and the List of Values is marked as Static.
 
Does this error suggest there is a problem with the formula, or a problem wiht the data that it's trying to interpret? Suggestions?
 
 
 
"Press any key to continue. Where's the 'Any' Key?" ~Homer Simpson
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2013 at 8:30am
most likely cuplprit is leap day.
You were likely running stuff for last year and it ws OK as it could convert a leap day into 2012. It can't do that for 2013.
Use a dateadd or dateserial instead


Edited by DBlank - 31 Jan 2013 at 10:04am
IP IP Logged
thummel1
Senior Member
Senior Member
Avatar

Joined: 27 Apr 2012
Location: United States
Online Status: Offline
Posts: 140
Quote thummel1 Replybullet Posted: 31 Jan 2013 at 8:36am
Thanks for your reply, but can you clarify something...what should I be swapping with DATEADD or DATESERIAL in my formula? Just wherever it says "Date"?
 
Thanks for clarifying.
"Press any key to continue. Where's the 'Any' Key?" ~Homer Simpson
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2013 at 10:19am
I was suggesting replacing the process of you uised to get the dates.
If you can explain what you are trying to accomplish in english I might be able to help alter the formula.
here is another post of a similar issue
 
IP IP Logged
thummel1
Senior Member
Senior Member
Avatar

Joined: 27 Apr 2012
Location: United States
Online Status: Offline
Posts: 140
Quote thummel1 Replybullet Posted: 01 Feb 2013 at 2:44am
Thanks, I reviewed the link. Here's what my report's supposed to do: The user enters a date via my date parameter. Then, the report is supposed to go out and look for anyone where their Master Entry Date month and day are between 1 and 14 days after the date entered in the date parameter.
 
Example: User enters 02/01/2013 in the date parameter. The report looks for all employees with a Master Entry Date Between 2/2 and 2/15 of any given year and returns those records.
 
This report was working fine until 2013. I am unclear how the formula should look if I use the DATEADD or DATEDIFF function...
"Press any key to continue. Where's the 'Any' Key?" ~Homer Simpson
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Feb 2013 at 3:57am
it was likely working fine because you were using a parmater date of 2012 which includes leap day, so as you were converting the your master entry dates to use 2012 as the year all the dates were valid.
Now as you use 2013 in your param, if it finds any entry date of Feb 29 it will fail becasue there is no 2-29-13 (29 is outside the month day range error).
if you use date add it accounts for changing leap day to I believe 2-28. I think dateserial changes it to 3-1.
Below is a formula to use with color coded break dowm of each part. I might have inverted something as I am not at a machine to test the formula out. 
1. get the years bewteen the param date and each entry date (purple)
2. add the resulting years to the entry date to make them have the same year value as the param date (red)
3. get the date diff value in days of the param date and the entry date (blue)
4. look ofr that result to be between 1 and 14 (black)
 
datediff('d',{?date},dateadd('yyyy',datediff('yyyy',{TAEEMASTER.MASTR_ENTRY},{?Date}),{TAEEMASTER.MASTR_ENTRY})) in 1 to 14


Edited by DBlank - 01 Feb 2013 at 3:58am
IP IP Logged
thummel1
Senior Member
Senior Member
Avatar

Joined: 27 Apr 2012
Location: United States
Online Status: Offline
Posts: 140
Quote thummel1 Replybullet Posted: 01 Feb 2013 at 7:09am
This worked! You guys are geniuses! Thank you so much!!
"Press any key to continue. Where's the 'Any' Key?" ~Homer Simpson
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum