| Author |
Message |
jbattelle
Newbie
Joined: 06 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
|

Topic: Converting a string to date YYYYMM Posted: 14 Jan 2013 at 11:50am |
Hi,
I have been trying to get this solved but cannot figure out how to convert a date that is stored as a string to convert to a date field in Crystal XI. I have the below setup but it isn't working and gives me an error stating "A number is missing here"
NumberVar YearPart; NumberVar MonthPart; WhilePrintingRecords; YearPart:= {PremiumSoa.YrMo}[1to4]; MonthPart:= {PremiumSoa.YrMo}[5to6]; Date (YearPart,MonthPart)
ANy help would be great. I do need to be able to do calculations.
Thanks,
Jason
|
IP Logged |
|
|
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 14 Jan 2013 at 12:10pm |
|
NumberVar YearPart; NumberVar MonthPart; WhilePrintingRecords; YearPart:= tonumber({PremiumSoa.YrMo}[1 to 4]); MonthPart:= tonumber({PremiumSoa.YrMo}[5 to 6]); Date (YearPart,MonthPart,1)
Edited by DBlank - 14 Jan 2013 at 12:11pm
|
IP Logged |
|
jbattelle
Newbie
Joined: 06 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
|

Posted: 14 Jan 2013 at 12:41pm |
Thanks. Worked perfectly.
|
IP Logged |
|
blowinup
Newbie
Joined: 09 Apr 2014
Online Status: Offline
Posts: 8
|

Posted: 09 Apr 2014 at 9:29am |
Originally posted by DBlank
NumberVar YearPart;NumberVar MonthPart; WhilePrintingRecords; YearPart:= tonumber({PremiumSoa.YrMo}[1 to 4]);MonthPart:= tonumber({PremiumSoa.YrMo}[5 to 6]); Date (YearPart,MonthPart,1)
This isn't working for me. When I try to save the formula below it generates an error indicating that the first section, the NumberVars, needs to be a number.
If I add a 1 to the end of the last line the error indicates to many arguments.
Help please.
NumberVar YearPart;
NumberVar MonthPart;
NumberVar DayPart;
WhilePrintingRecords;
YearPart:= tonumber({person.date_of_birth}[1 To 4]);
MonthPart:= tonumber({person.date_of_birth}[5 To 6]);
DayPart:= tonumber({person.date_of_birth}[7 To 8]);
Date (YearPart,MonthPart,DayPart)
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 09 Apr 2014 at 9:38am |
|
What data type is your raw data and what are some sample rows?
|
IP Logged |
|
blowinup
Newbie
Joined: 09 Apr 2014
Online Status: Offline
Posts: 8
|

Posted: 09 Apr 2014 at 9:54am |
Originally posted by DBlank
What data type is your raw data and what are some sample rows?
string(8)
20140328
20140328
20140328
20140329
20140329
20140329
20140330
20140330
20140331
20140331
20140402
20140403
20140403
20140406
20191030
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 09 Apr 2014 at 9:59am |
date(mid(field,5,2)+'/'+right(field,2)+'/'+left(field,4))
|
IP Logged |
|
blowinup
Newbie
Joined: 09 Apr 2014
Online Status: Offline
Posts: 8
|

Posted: 09 Apr 2014 at 10:19am |
|
Thanks so much for your quick help with this. Unfortunately I am getting an error when I plug in my field like this:
date(mid(person.date_of_birth,5,2)+'/'+right(person.date_of_birth,2)+'/'+left(person.date_of_birth,4))
The error reads "The ) is missing" and highlites the first person like this:
date(mid([person.date_of_birth,5,2)+'/'+right(person.date_of_birth,2)+'/'+left(person.date_of_birth,4))
|
IP Logged |
|
blowinup
Newbie
Joined: 09 Apr 2014
Online Status: Offline
Posts: 8
|

Posted: 09 Apr 2014 at 10:24am |
|
I also tried this and now I get an error that read, "A string is required here".
I get this same error when attempting to use 3 other formulas that reportedly work for others.
What am I doing wrong?
|
IP Logged |
|
blowinup
Newbie
Joined: 09 Apr 2014
Online Status: Offline
Posts: 8
|

Posted: 09 Apr 2014 at 10:29am |
Originally posted by blowinup
I also tried this and now I get an error that read, "A string is required here".
I get this same error when attempting to use 3 other formulas that reportedly work for others.
What am I doing wrong?
Sorry, I forgot to include the formula that generates the error.
date(mid({person.date_of_birth},5,2)+'/'+right({person.date_of_birth},2)+'/'+left({person.date_of_birth},4))
|
IP Logged |
|
|
|