Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formating String field to Date data type/value Post Reply Post New Topic
Author Message
anishpyne
Newbie
Newbie


Joined: 11 Feb 2008
Online Status: Offline
Posts: 1
Quote anishpyne Replybullet Topic: Formating String field to Date data type/value
    Posted: 11 Feb 2008 at 11:47am
I am trying to generate a report from a text file which has fields delimited using the '|' characters. One of the fields section represents a timestamp, however when using the file its getting treated as type string by Crystal Reports XI. 
 
Can you somebody please suggest how Crystal Reports can be made to
treat this as a 'date' data type.
 
Sample row from the text file:-
 
Mon Jan 14 00:15:03 EST 2008|230|http://www.xptopstories.com/login
 
I want Crystal Reports to treat the first field as a date value, i.e. 14th Jan 2008.
 
I need to do grouping, maximum, etc on this field treating it as a date.


Edited by anishpyne - 11 Feb 2008 at 11:48am
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 12 Feb 2008 at 3:30am
Hi,
 

    Mon Jan 14 00:15:03 EST 2008|230|http://www.xptopstories.com/login

    Mon Jan 14 00:15:03 EST 2008   Jan 14    14th               2008   Jan

   14th Jan  2008|230|http://www.xptopstories.com/login

 

    Mon Jan 1  00:15:03 EST 2008|230|http://www.xptopstories.com/login

    Mon Jan 1  00:15:03 EST 2008   Jan 1     1st                2008   Jan

    1st Jan  2008|230|http://www.xptopstories.com/login

 

     Mon Jan 22 00:15:03 EST 2008|230|http://www.xptopstories.com/login

     Mon Jan 22 00:15:03 EST 2008   Jan 22    22nd              2008   Jan

     22nd Jan  2008|230|http://www.xptopstories.com/login

 
To get the above result  use the following formulas
 
Extract Date :--   LEFT({TestDate_txt.DETAILS},28)
 
GetJan14:-mid({@ExtractDate},5,7)
 
Suffixfor Date :-
 
stringvar daynumber := trim(mid(totext({@GetJan14}),5));
select daynumber
case "1", "21", "31","01":
daynumber & "st"
case "02", "22":
daynumber & "nd"
case "03", "23":
daynumber & "rd"
default:
daynumber & "th";
Year:-
 
Mon:-
 
 
AfterDateDetails :-
Mid({TestDate_txt.DETAILS},29)
 
 
Combine:-
trim({@Suffix for Date}+ " " + {@mon}+ " " +{@Year})
 
 
Once you have done that create a TextBox Place it in details section Then Place the Combine formula in first place and AfterDateDetails formula in secon place....
 
Cheers
Rahul
 
IP IP Logged
Alex
Newbie
Newbie


Joined: 28 Jan 2008
Location: Canada
Online Status: Offline
Posts: 22
Quote Alex Replybullet Posted: 12 Feb 2008 at 7:48am
What is it with http://www.xptopstories.com/login link? I can't open it.
I have one quick question I know it's is of topic subject... sorry.
Can someone educate me how to post screen shots in case I need for future reference.
Thanks,
Alex
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.