Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Converting a string to date YYYYMM Post Reply Post New Topic
<< Prev  Page  of 2
Author Message
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Apr 2014 at 10:45am
My guess is it is not a string but rather a numeric field
try
 
NumberVar YearPart;
NumberVar MonthPart;
NumberVar DayPart;
StringVAr DateText;

WhilePrintingRecords;
DateText:=totext({person.date_of_birth},0,'');
YearPart:= tonumber(DateText [1 To 4]);
MonthPart:= tonumber(DateText [5 To 6]);
DayPart:= tonumber(DateText [7 To 8]);
Date (YearPart,MonthPart,DayPart)
IP IP Logged
blowinup
Newbie
Newbie


Joined: 09 Apr 2014
Online Status: Offline
Posts: 8
Quote blowinup Replybullet Posted: 09 Apr 2014 at 1:58pm
The database and Crystal both indicate that it is a string.

This is one of the other formulas I tried without success. I copied and pasted yours hoping that perhaps it would work but unfortunately it did not.

I got an error that read, "To many arguments have been given to this function" and it highlited the following section:

NumberVar YearPart;
NumberVar MonthPart;
NumberVar DayPart;
StringVAr DateText;

WhilePrintingRecords;
DateText:=totext({person.date_of_birth},0,'');
YearPart:= tonumber(DateText [1 To 4]);
MonthPart:= tonumber(DateText [5 To 6]);
DayPart:= tonumber(DateText [7 To 8]);
Date (YearPart,MonthPart,DayPart)


Edited by blowinup - 09 Apr 2014 at 2:03pm
IP IP Logged
blowinup
Newbie
Newbie


Joined: 09 Apr 2014
Online Status: Offline
Posts: 8
Quote blowinup Replybullet Posted: 09 Apr 2014 at 2:17pm
This may be a silly question, but where should I be entering this in Crystal? I've been putting it in Format Editor\Common Tab\Display String. Is that right?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 10 Apr 2014 at 5:22am
I believe you would be creating a formula.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Apr 2014 at 6:16am
As kevlray indicates,  it would be in the Field Explorer as a new formula field.
Where you were putting it could work as simply altering the display output but would not convert it to a usable date field
 
after you create the formula field drag and drop it onto the report canvas to replace the original field


Edited by DBlank - 10 Apr 2014 at 6:17am
IP IP Logged
<< Prev  Page  of 2
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