Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Edit Mask Numeric Field??? Post Reply Post New Topic
Author Message
siweltj
Newbie
Newbie


Joined: 13 Sep 2007
Location: United States
Online Status: Offline
Posts: 16
Quote siweltj Replybullet Topic: Edit Mask Numeric Field???
    Posted: 23 Aug 2012 at 4:54am
Here is my dilemma - I have a SQL data set where a date field is an 8 digit numeric field as yyyymmdd. My report uses a parameter field to select the date based on user input. However users occasionally enter non-numeric characters such as commas or periods. When this occurs the SQL database freezes until the user ends program.

I was hoping to use edit mask but seems that can not work on numeric fields. Ideally this field is presented to the user as a date field however I have no way to edit the SQL database. Suggestions?


Thanks


Edited by siweltj - 23 Aug 2012 at 5:15am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Aug 2012 at 5:15am
make the param a date type to force proper selection and covert your database field in the select statement
{?date}=date(mid(totext(field,0,''),5,2)+'/'+right(totext(field,0,''),2) + '/' +left(totext(field,0,''),4))
IP IP Logged
siweltj
Newbie
Newbie


Joined: 13 Sep 2007
Location: United States
Online Status: Offline
Posts: 16
Quote siweltj Replybullet Posted: 23 Aug 2012 at 5:47am
Thank you for the help, however gave that a try and get a "Bad Date Format" error in Record Selection. Below is my record selection formula:

{?Date} =date(mid(totext({Schedules.LDate},0,''),5,2)+'/'+right(totext({Schedules.LDate},0,''),2) + '/' +left(totext({Schedules.LDate},0,''),4)) and
{EventStrings.TripCount} > 0 and
{EventStrings.EvStrName} in {?From Route} to {?To Route}      

Edited by siweltj - 23 Aug 2012 at 5:58am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Aug 2012 at 5:59am
are you sure the Schedules.LDate is a numeric type or is it really a string that allawys has 8 numbers? Can it be blank or null?
IP IP Logged
siweltj
Newbie
Newbie


Joined: 13 Sep 2007
Location: United States
Online Status: Offline
Posts: 16
Quote siweltj Replybullet Posted: 23 Aug 2012 at 6:16am
Below is sample of the data from the field which is a number field. Although there is a zero in the data, this would never be a part of the selection:

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Aug 2012 at 6:19am
if it exists it can still choke the formula on that row
try
(
{Schedules.LDate}>0 and
{?Date} = date(mid(totext({Schedules.LDate},0,''),5,2)+'/'+right(totext({Schedules.LDate},0,''),2) + '/' +left(totext({Schedules.LDate},0,''),4))
)
and
{EventStrings.TripCount} > 0 and
{EventStrings.EvStrName} in {?From Route} to {?To Route}      
IP IP Logged
siweltj
Newbie
Newbie


Joined: 13 Sep 2007
Location: United States
Online Status: Offline
Posts: 16
Quote siweltj Replybullet Posted: 23 Aug 2012 at 7:16am
Thank you, that works. Downside is that it has significantly increased processing time on the report and CPU usage on server side. 500 page report took nearly 10 minutes and 90%+ of peak CPU.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Aug 2012 at 7:43am
try and reverse it the conversion to see if it runs better
 
tonumber(totext({?Date},('yyyyMMdd')))={Schedules.LDate}
IP IP Logged
siweltj
Newbie
Newbie


Joined: 13 Sep 2007
Location: United States
Online Status: Offline
Posts: 16
Quote siweltj Replybullet Posted: 23 Aug 2012 at 7:57am
Tremendous improvement. Well done. Thank you.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.047 seconds.