?
Solved

How to convert a text field to date in crystal reports

Posted on 2008-10-09
4
Medium Priority
?
640 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
[X]
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
  • 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 375 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 101

Assisted Solution

by:mlmcc
mlmcc earned 375 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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 …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

777 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