Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: A day number must be between 1 and the...... error Post Reply Post New Topic
Page  of 2 Next >>
Author Message
Shales
Newbie
Newbie


Joined: 17 Jan 2013
Online Status: Offline
Posts: 10
Quote Shales Replybullet Topic: A day number must be between 1 and the...... error
    Posted: 30 Jan 2013 at 2:25am
Hello,
 
I am really struggling to write a report and I am looking for some help.
 
First of all I am using this formula which is the major driving formula in my report
 
IIF(DATE(YEAR(TODAY()),MONTH({@Date Pol COm}),DAY({@Date Pol COm})) < TODAY(),DATE(YEAR(TODAY())+1,MONTH({@Date Pol COm}),DAY({@Date Pol COm})),DATE(YEAR(TODAY()),MONTH({@Date Pol COm}),DAY({@Date Pol COm})))
 
What this is doing is taking the clients start date and then seeing if the anniversary has passed this year or is due this year. If the anniversary has passed it displays the date 29/01/2014 as today is 30/01/2013.
 
This works ok which is great.
 
The problem is, I am looking for all plans that have yesterday's date. If I try any selection criteria using this formula field it displays the following message;
 
"A day number must be between 1 and the number of days in the month"
 
I can't even sort the report using this column. I am confused. Please can anybody help. Maybe there is a better way of writing my formula?
 
Regards
Gavin
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jan 2013 at 4:32am
what is your @Date Pol Com formula?
IP IP Logged
Shales
Newbie
Newbie


Joined: 17 Jan 2013
Online Status: Offline
Posts: 10
Quote Shales Replybullet Posted: 30 Jan 2013 at 4:37am
It's just;
 
date({POLICYINFORMATIONVW.POLICYCOMMDATE})
 
I was just trying to convert the field first before using it in the formula to see if that worked.
 
The formula doesn't work with just ({POLICYINFORMATIONVW.POLICYCOMMDATE}) either. This field is DATETIME, but the time is always 00:00:00
 
Don't know if that helps?
 
Thanks for looking
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jan 2013 at 4:39am
so you want yesterdays date if the anniversary is passed for the year and the actual anniversary date if it has not correct?
IP IP Logged
Shales
Newbie
Newbie


Joined: 17 Jan 2013
Online Status: Offline
Posts: 10
Quote Shales Replybullet Posted: 30 Jan 2013 at 4:41am
Also, I am now using the above formula without the "+1" as I am looking for the formula to just return current YYYY. It would have been impossible to find yestersdays date otherwise.
IP IP Logged
Shales
Newbie
Newbie


Joined: 17 Jan 2013
Online Status: Offline
Posts: 10
Quote Shales Replybullet Posted: 30 Jan 2013 at 4:44am
Sorry, we replied at the same time.
 
Basically I am now just looking at the ({POLICYINFORMATIONVW.POLICYCOMMDATE}) which could be 2007, 2008 etc, and I want them all to be current YYYY.
 
That way I can find the plans that had their anniversary yesterday - (today -1)


Edited by Shales - 30 Jan 2013 at 4:48am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jan 2013 at 4:48am
how are you handling leap years?
IP IP Logged
Shales
Newbie
Newbie


Joined: 17 Jan 2013
Online Status: Offline
Posts: 10
Quote Shales Replybullet Posted: 30 Jan 2013 at 4:58am
er.... not sure. I am hoping that a leap year wouldn't impact the formula.
 
I haven't even considered leap years. I have had a look at my data and there are no plans that commenced on 29/02/2012 or 29/02/2008
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jan 2013 at 5:33am
 
one way to convert to current year:
dateadd('yyyy',datediff('yyyy',{POLICYINFORMATIONVW.POLICYCOMMDATE},currentdate),{POLICYINFORMATIONVW.POLICYCOMMDATE})
 
one way to find any for yesterday:
datediff('d',dateadd('yyyy',datediff('yyyy',{POLICYINFORMATIONVW.POLICYCOMMDATE},currentdate),{POLICYINFORMATIONVW.POLICYCOMMDATE}),currentdate)=1
IP IP Logged
Shales
Newbie
Newbie


Joined: 17 Jan 2013
Online Status: Offline
Posts: 10
Quote Shales Replybullet Posted: 30 Jan 2013 at 5:40am
Thanks v much for the formulas. I shall try this first thing in the morning.
 
Regards
Gavin
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.