Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: date format Post Reply Post New Topic
Author Message
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Topic: date format
     Posted: 07 Aug 2012 at 10:54am
I have a file with a date which is in a string MMDDYY.   I want to know how I can get it into the date format YYMMDD.  Thanks!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 08 Aug 2012 at 3:38am
Look at the Left(), Right() and Mid() functions that are available in the Formula editor.
 
-Dell
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 08 Aug 2012 at 4:20am
HI
 
Try this :
 
date(tonumber(right({databasefield},2)),tonumber(left({databasefield},2)),tonumber(mid({databasefield},3,2)))
 
 
Thanks,
Sastry
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 08 Aug 2012 at 6:16am
Hi Sastry,
 
Thank you.   I tried this but I'm getting date to come out in same format  (example)  060812 is coming out as 06/08/12.   What I'm looking for is to get it to come out like this:  120608.   (so that i can sort it by year, month, day) 
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 08 Aug 2012 at 6:18am

Thank you Hilfy.  I am able to use the function to separate out month, day and year into 3 separate fields, but how would I get it to make one field?  example:  I want the original string 060812 to come out like this: 120608 so that it is sortable by year first, then month, then day.

 

 

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Aug 2012 at 6:40am

Dell's sugesstion would apply as:

right({databasefield},2) + left({databasefield},2) + mid({databasefield},3,2)
 
or use Sastry's suggestion to covert it to a date type and then use the format options on that formaul field to dispaly as desired (right click and select Format field and use the date tab to manage the display string)
 
or this would also do it
totext(date(picture({table.datefield},"xx/xx/xx")),"yyMMdd")
 


Edited by DBlank - 08 Aug 2012 at 6:41am
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 08 Aug 2012 at 7:34am

Got it!  Thank you so much to everyone!  Tongue

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