Skip to Content

Broken CStr function in Crystal Reports

Hello Everyone,

I have a new weird issue. I have a formula that has been working fine until yesterday.

The db I am querying is using a year month string to query a database. So I created the following code to convert a calculated date into the string I needed. It has been working fine until yesterday.

Here is the code I am using

{?Date} = inputted date

{@Date.4} = calculated date

{@Date_4} = the string of yyyymm I need for the querry/

Formula "Date.4": DATE (DateAdd ("m",-4 ,{?Date}))

Formula "Date_4":

if MONTH({@date.4}) < 10 then CStr (YEAR ({@date.4})) & '0' & CStr (MONTH ({@date.4})) else CStr (YEAR ({@date.4})) & CStr (MONTH ({@date.4}))

the formula is returning "2016.0003.00"

It used to return "201603" (and that is what I need)

Can you see why this might be returning the wrong values?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jul 20, 2016 at 05:47 PM

    I have broken down the values and found the issue is that the 'Year({@date.4})" =2016.00 and month is similar creating the decimal and two '00' - this is my problem.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.