cancel
Showing results for 
Search instead for 
Did you mean: 

String to number and Number to String Problem!

Former Member
0 Kudos

Hi All,

In my report i ahve to display the Date.

From DB i am getting 4 digit string( 2008). Using that i have to display as 08 - 09

In that i used RIGHT function. it is diplayed as 08 - 9.

when i take 2 character from right '08' is coming. Then i converted to number and added 1 to the year

But it become 9 instead of 09.

How to solve it.

Thanks in advance.

Saravanakumar.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Shweta's answer is valid when you retrieve a date field from the database, as you have specified that you are getting a four digit string, you should use this formula.

if length(totext(tonumber(right('2008',2))+1)) = 4

then

right('2008',2)'-0'left(totext(tonumber(right('2008',2))+1),1)

else

right('2008',2)'-'left(totext(tonumber(right('2008',2))+1),2)

hope this helps!!!

Thanks

-Azhar

Edited by: Abdul Rehman Mushtaque on Mar 29, 2009 10:29 AM

Former Member
0 Kudos

Hi Saravana,

You can format date in Crystal report design as per your requirement.

Right click on Feild in CR design ->Format field.

Regards,

Shweta