Solved

Crystal Reports Show date from prior month

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
If your app took Google’s lash recently, here are the 5 most likely reasons.
This video demonstrates basic masking and how to edit the mask to reveal the desired image.
The viewer will learn common shortcuts with easy ways to remember them. The viewer will then learn where to find all of the keyboard shortcuts, how to create/change them, and how to speed up their workflow.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now