Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Converting number to date field Post Reply Post New Topic
Author Message
jbattelle
Newbie
Newbie


Joined: 06 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
Quote jbattelle Replybullet Topic: Converting number to date field
     Posted: 28 Feb 2012 at 11:51am
Hi,
 
I am trying to convert a number to a date field. Currently, my dates come in in the following format: 08011990 or mmddyyyy I need them to be converted to: 08/01/1900 or mm/dd/yyyy.
 
Using Crystal XI
 
Thanks a ton for your help!!!!
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 28 Feb 2012 at 12:01pm
I have done something like this in the past.  The way that I did was the following

local stringvar datestr := totext({datenumberfield});
left(datestr,2)+"/"+mid(datestr,3,2)+"/"+right(datestr,4)

Of course the {datenumberfield} would actually be whatever field has your date value.

I hope this helps.
IP IP Logged
jbattelle
Newbie
Newbie


Joined: 06 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
Quote jbattelle Replybullet Posted: 28 Feb 2012 at 12:04pm
Dude you are a genius!! I have sat here most of the day trying to get this to work with a CDATE formula. I get some of the programming in this formula, but not sure what the +MID(datestr,3,2) is.  Can you calrify just for my knowledge? It worked perfectly though. Thanks a ton.
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 28 Feb 2012 at 11:11pm
The MID(datestr,3,2) extracts the DD from your number.
 
The 2 represents how many characters to extract from your string, and the 3 tells it where to start in the string, ie extract 2 characters starting with the 3rd. 12345678.
 
Hope that helps.
 
Regards,
Ryan.
IP IP Logged
jbattelle
Newbie
Newbie


Joined: 06 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
Quote jbattelle Replybullet Posted: 29 Feb 2012 at 3:05am
Makes sense. Thanks man.
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