Solved

Crystal Reports Show date from prior month

Posted on 2014-01-16
4
595 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 101

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
If your app took Google’s lash recently, here are the 5 most likely reasons.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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