Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: String NonNumeric Post Reply Post New Topic
Author Message
Juststarting
Newbie
Newbie
Avatar

Joined: 30 Dec 2010
Location: United States
Online Status: Offline
Posts: 8
Quote Juststarting Replybullet Topic: String NonNumeric
     Posted: 17 May 2011 at 10:46am
I'm trying to convert a date formatted as a number 20110105 to 01/05/2011, but I receive a message "String is Non Numeric", any suggestions?
 
if not ISNULL({Command.MLIDDT})then DATE(CDBL(LEFT(CSTR({Command.MLIDDT},0,""),4)),if not ISNULL({Command.MLIDDT})then  CDBL(MID(CSTR({Command.MLIDDT},0,""),5,2)), if not ISNULL({Command.MLIDDT})then CDBL(RIGHT(CSTR({Command.MLIDDT},0,""),2)))
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 May 2011 at 3:21am
how about the simple approach:
 
local stringvar d := {table.field};
if not isnull(d) then
  DATE(mid(d,5,2)+"/"+mid(d,7,2) + "/" + left(d,4))
 
 
HTH
IP IP Logged
Juststarting
Newbie
Newbie
Avatar

Joined: 30 Dec 2010
Location: United States
Online Status: Offline
Posts: 8
Quote Juststarting Replybullet Posted: 18 May 2011 at 3:49am
HTH, thanks for the response.    Here's what I have, I receive message A String is required here, {Command.MLIDDT} when declare the variable.  
 
 local stringvar d := {Command.MLIDDT};
if not isnull({Command.MLIDDT}) then
  DATE(mid(d,5,2)+"/"+mid(d,7,2) + "/" + left(d,4))  DATE(mid(d,5,2)+"/"+mid(d,7,2) + "/" + left(d,4))
 
I changed to:
local numbervar d := {Command.MLIDDT};
if not isnull({Command.MLIDDT}) then
  DATE(mid(d,5,2)+"/"+mid(d,7,2) + "/" + left(d,4))
 
Then receive message 'A String is required here'  for  'd'  in DATE(mid(d,5,2)+"/"+mid(d,7,2) + "/" + left(d,4)).
 
any help is appreciated.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 May 2011 at 4:06am
What sort of field is the MLIDDT field?  I was assuming that it was a string.
 
I would try d:= toText({table.field}, 0, "").  If CR thinks it is a number, this will format it without a decimal or trailing zeros.
 
if it is not a number, I would just try a generic toText()...and to see what CR is converting it to, I would create a simple fomula like:
 
toText({table.field}) and dropping it on the report where appropriate.  From there you will probably be able to determine how to tell CR to format it so that you get the string that you are after.
 
HTH
IP IP Logged
Juststarting
Newbie
Newbie
Avatar

Joined: 30 Dec 2010
Location: United States
Online Status: Offline
Posts: 8
Quote Juststarting Replybullet Posted: 18 May 2011 at 4:26am
HTH - I figured it out.
 
The formula didn't like when MLIDDT field contained a '0' instaed of a real date. I think this cuased the formula to attempt to pass an empty string as 'month' parameter for the DATE() function, which is when it was expecting a numeric value.
 
if not ISNULL({command.MLIDDT}) and {COMMAND.mliddt} > 0 then
DATE(CDBL(LEFT(CSTR({command.MLIDDT},0,""),4)),
     CDBL(MID (CSTR({command.MLIDDT},0,""),5,2)),
     CDBL(RIGHT(CSTR({command.MLIDDT},0,""),2)))
IP IP Logged
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