• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

Crystal Reports Show date from prior month

I have a report that is now failing as it pulls the last month and now in january it is getting stuck. this is my code the code after the FIRST ELSE is causing the issue. Error in CRS is Month must be between 1 and 12.

if {INVITEMS.WRKORDNBR} = 0
    then
    monthname(month({INVOICE.DATE})) + " " + cstr(year({INVOICE.DATE}),0,"") + " - Contract"
    else
    monthname(month({INVOICE.DATE})-1) + " " +  if month({INVOICE.DATE}) -1 = 12
       then  totext(year({INVOICE.DATE})-1,0,"") else totext(year({INVOICE.DATE}),0,"") + " - OOS"
0
mikeg95
Asked:
mikeg95
  • 2
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
do a seperate else if:

else   if month(({INVOICE.DATE})-1) = 0
      then MonthName (12) + " " +  totext(year({INVOICE.DATE})-1,0,"")
   else
      ' normal logic
0
 
mlmccCommented:
Actually since you are first test for the workorder number the test for the month number will come in the else part

if {INVITEMS.WRKORDNBR} = 0  then
    monthname(month({INVOICE.DATE})) + " " + cstr(year({INVOICE.DATE}),0,"") + " - Contract"
else if Month({INVOICE.DATE}) = 1 then
     monthname(12) + " " +  totext(year({INVOICE.DATE})-1,0,"")
Else
    monthname(month({INVOICE.DATE})-1) + " " +  totext(year({INVOICE.DATE}),0,"")

mlmcc
0
 
mikeg95Author Commented:
I tried this and still getting same error

if {INVITEMS.WRKORDNBR} = 0
    then
    monthname(month({INVOICE.DATE})) + " " + cstr(year({INVOICE.DATE}),0,"") + " - Contract"
    else
    monthname(month({INVOICE.DATE})-1) + " " +  if month(({INVOICE.DATE})-1) = 0
      then MonthName (12) + " " +  totext(year({INVOICE.DATE})-1,0,"") else cstr(year({INVOICE.DATE}),0,"") + " - OOS"
0
 
mikeg95Author Commented:
works perfect
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now