Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to convert a text field to date in crystal reports

Posted on 2008-10-09
4
Medium Priority
?
647 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

597 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