Solved

How to convert a text field to date in crystal reports

Posted on 2008-10-09
4
633 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now