Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: string to date conversion Post Reply Post New Topic
Author Message
remintgon
Newbie
Newbie


Joined: 07 May 2008
Online Status: Offline
Posts: 4
Quote remintgon Replybullet Topic: string to date conversion
     Posted: 25 May 2011 at 6:01am
Newbi here,

I have a string that is yyyyddmm in the database when I pull it to the report is shows as 20110518, I need to show it as 05/18/2011. I how do I convert this? and where do I put the formula?

Thank you
Thanks for everything
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 25 May 2011 at 6:05am
create a new formula

realistically if you dont need to evaluate you can just do this

right(#date,2) + '/' + mid(#date, 5,2) + '/' + left(#date, 4)

IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 25 May 2011 at 6:06am
Originally posted by comatt1

create a new formula

realistically if you dont need to evaluate you can just do this

right(#date,2) + '/' + mid(#date, 5,2) + '/' + left(#date, 4)



this would create a string value and if you need to use it as a date just put this within a cdate function
IP IP Logged
remintgon
Newbie
Newbie


Joined: 07 May 2008
Online Status: Offline
Posts: 4
Quote remintgon Replybullet Posted: 25 May 2011 at 6:20am
Thanks for the replay comatt1,

I am a really newb when it comes to CR. I have a field that is {AR_OPEN_ITEMS.DUE_DATE} using what you gave me how do I get that field to display 05/25/2011 when the string is 20110525. Do I go to x-1 formula fields? I am lost.

Thanks
Thanks for everything
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 25 May 2011 at 8:45am

Do it like this

create a formula field - yes the icon is an x-1.

within the formula field enter (without the "-")

-------------------------

right({AR_OPEN_ITEMS.DUE_DATE,2) + '/' + mid({AR_OPEN_ITEMS.DUE_DATE, 5,2) + '/' + left({AR_OPEN_ITEMS.DUE_DATE, 4)

---------------------------------
There are other ways of converting the date, but this will work.

Let me know how it works out
IP IP Logged
Dewald
Groupie
Groupie
Avatar

Joined: 02 Jun 2011
Location: South Africa
Online Status: Offline
Posts: 47
Quote Dewald Replybullet Posted: 02 Jun 2011 at 5:37am

You can take comatt1's suggestion further

date(left(({AR_OPEN_ITEMS.DUE_DATE},4) & "/" & mid(({AR_OPEN_ITEMS.DUE_DATE},5,2) & "/" & right(({AR_OPEN_ITEMS.DUE_DATE},2))
 
This will make the date a valid date and you will be able to use it in other formulas as a date.
 
Dewald Botha
http://www.ITClarity.co.za
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum