Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Month number must be between 1 and 12 1

Status
Not open for further replies.

Bennie47250

Programmer
Nov 8, 2001
515
US
Using Crystal CR Developer version 14.0.4.738 and a MS SQL database

Was using this formula in Crystal version 7.0 without any issues but in version 14 it throws the error "Month number must be between 1 and 12".

The formula is: {@DateClosed} in Date (Year (CurrentDate),Month (CurrentDate)-1 , 16) to Date (Year (CurrentDate),Month (CurrentDate) ,1 )-1

When checking the formula it is highlighting this part "Date (Year (CurrentDate),Month (CurrentDate)-1 , 16)"

I suspect the issue is with "Month (CurrentDate)-1" since this is month 1 when it subtracts 1 it leaves 0.

Apparently Crystal 7 was smart enough to know this is a date and when you are in month 1 that subtracting 1 is 12 not 0.

Is there another data function I should be using that know when in month 1 subtracting 1 is 12 not 0?

Thanks Bennie
 
Sounds like you need use the datediff or dateadd functions. They handle the month change nicely. I am not sure what you are trying to accomplish with your formula.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top