Skip to Content
0
Former Member
Jun 29, 2016 at 12:12 PM

Days in a month

245 Views

Hie guys

I have the below formula that should pull the day in the next month. When I run crystal reports it gives the error "A day number must be between 1 and the number of days in a month crystal reports error" I assume that is because 31 does not exist in the current or next month, for instance there is no 31 June. How do I modify the below formula to consider the days in a month.

IF ISNULL({CASE_EXTRA.FIELD055_DATE}) OR {CASE_EXTRA.FIELD055_DATE}=DATE(0,0,0) THEN

IF PrintDate > DATE(DatePart ("yyyy",PrintDate ),DatePart ("m",PrintDate ),{DEBITORDERARRANGEMENT.DAYOFMONTH}) THEN

DATE(DatePart ("yyyy",PrintDate ),(DatePart ("m",PrintDate ) + 1),{DEBITORDERARRANGEMENT.DAYOFMONTH})

ELSE

DATE(DatePart ("yyyy",PrintDate ),DatePart ("m",PrintDate ),{DEBITORDERARRANGEMENT.DAYOFMONTH})

ELSE

IF PrintDate > {CASE_EXTRA.FIELD055_DATE} THEN

DATE(DatePart ("yyyy",{CASE_EXTRA.FIELD055_DATE} ),(DatePart ("m",{CASE_EXTRA.FIELD055_DATE} ) + 1),DatePart ("d",{CASE_EXTRA.FIELD055_DATE} ))

ELSE

{CASE_EXTRA.FIELD055_DATE}

;