Solved

Crystal Reports Show date from prior month

Posted on 2014-01-16
4
580 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
  • 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

773 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