Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Convert Date Post Reply Post New Topic
Author Message
pjgreports
Newbie
Newbie
Avatar

Joined: 29 Jul 2011
Online Status: Offline
Posts: 14
Quote pjgreports Replybullet Topic: Convert Date
     Posted: 01 Aug 2011 at 11:21am
I have a field {PAUDIT.DATE} in my report that brings the date displayed as YYYYMMDD.  example: 20110601.  I need to convert date to 06/01/2011/ .  I have tried using CDATE function but i am having no luck unless i am doing something wrong here.  Can anyone help ? Thanks in advance !
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Aug 2011 at 11:52am

date(mid({PAUDIT.DATE},5,2) + '/' + right({PAUDIT.DATE},2) + '/' + left({PAUDIT.DATE},4))

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Aug 2011 at 11:54am
once it is set as a date type field you can make it formatted to whatever you preference is using the field format options in the Format Editor and Date tab

Edited by DBlank - 01 Aug 2011 at 11:55am
IP IP Logged
jason stratom
Newbie
Newbie


Joined: 17 Feb 2011
Location: India
Online Status: Offline
Posts: 21
Quote jason stratom Replybullet Posted: 02 Aug 2011 at 11:20pm
Hi ,
             Right click on that field in the report

Format field-->custom style-->customise and Date.
In the date tab u can choose your own date format.
Try this it will be simple.........or else if u r using SQL cmd
convert(varchar(10),(ur date field),104)......also u can try for numbers from 101 to 110..........

Regards,
Jason

Edited by jason stratom - 02 Aug 2011 at 11:21pm
IP IP Logged
pjgreports
Newbie
Newbie
Avatar

Joined: 29 Jul 2011
Online Status: Offline
Posts: 14
Quote pjgreports Replybullet Posted: 04 Aug 2011 at 10:18am
Thank you for the info. i have implemented this.
date(mid({PAUDIT.DATE},5,2)+'/'+right({PAUDIT.DATE},2)+'/'+left({PAUDIT.DATE},4)) .  I now cannot get passed the error " A string is required here."  This is a string and when I click ok it goes to the date function. 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Aug 2011 at 10:49am
is {PAUDIT.DATE} a numeric or string type field? My original post assumed it was a string.
If it is numeric try
 
date(mid(totext({PAUDIT.DATE},0,''),5,2)+'/'+right(totext({PAUDIT.DATE},0,''),2)+'/'+left(totext({PAUDIT.DATE},0,''),4))


Edited by DBlank - 04 Aug 2011 at 11:56am
IP IP Logged
pjgreports
Newbie
Newbie
Avatar

Joined: 29 Jul 2011
Online Status: Offline
Posts: 14
Quote pjgreports Replybullet Posted: 05 Aug 2011 at 5:36am
Yes this is a string data type.  example of data in field is 20110601.   I get an error:  "Too many arguments have been given to this function." 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Aug 2011 at 8:34am
using my original suggestion
date(mid({PAUDIT.DATE},5,2)+'/'+right({PAUDIT.DATE},2)+'/'+left({PAUDIT.DATE},4))
make sure you are using this as crystal syntax (not basic syntax)
IP IP Logged
pjgreports
Newbie
Newbie
Avatar

Joined: 29 Jul 2011
Online Status: Offline
Posts: 14
Quote pjgreports Replybullet Posted: 08 Aug 2011 at 7:49am
That worked ! Thanks so much for your help !
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