Solved

Crystal Reports Show date from prior month

Posted on 2014-01-16
4
588 Views
Last Modified: 2014-01-16
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
Comment
Question by:mikeg95
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 39786707
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
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39786733
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
 

Author Comment

by:mikeg95
ID: 39786771
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
 

Author Closing Comment

by:mikeg95
ID: 39786856
works perfect
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.
Viewers will learn how to use the Hootsuite Dashboard.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question