Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to convert a text field to date in crystal reports

Posted on 2008-10-09
4
635 Views
Last Modified: 2012-06-21
I have a field which is of type string and looks like:   20080115 (ie YYYY-mm-dd)

Is there an easier way to convert it to type date than the following formula?


Local StringVar DaypartTemp;
Local StringVar MonthpartTemp;
Local StringVar YearpartTemp;
Local NumberVar Daypart ;
Local NumberVar MonthPart;
Local NumberVar YearPart ;

DayParttemp := Right({V_My_Portfolio_1.Manager Date From}, 2);
MonthParttemp := Mid({V_My_Portfolio_1.Manager Date From}, 5,2);
YearParttemp := Left({V_My_Portfolio_1.Manager Date From}, 4);

Daypart := ToNumber(DaypartTemp);
MonthPart := ToNumber(MonthpartTemp);
YearPart := ToNumber(YearpartTemp);

Date (YearPart,MonthPart,DayPart )



0
Comment
Question by:BostonMA
  • 2
4 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 22682142
You can just put it all together like this:
DATE(Left({V_My_Portfolio_1.Manager Date From}, 4),
Mid({V_My_Portfolio_1.Manager Date From}, 5,2), Right({V_My_Portfolio_1.Manager Date From}, 2))
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 125 total points
ID: 22682182
Sorry, you'll still need to use "ToNumber":

DATE(ToNumber(Left({V_My_Portfolio_1.Manager Date From}, 4)),
ToNumber(Mid({V_My_Portfolio_1.Manager Date From}, 5,2)), ToNumber(Right({V_My_Portfolio_1.Manager Date From}, 2)))
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 125 total points
ID: 22682829
As far as execution goes, they will be about the same.

mlmcc
0
 
LVL 4

Author Closing Comment

by:BostonMA
ID: 31504815
Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question