Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: select record on date which is string in the DB Post Reply Post New Topic
Author Message
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Topic: select record on date which is string in the DB
     Posted: 08 May 2009 at 11:37pm
Hi,
 
How to select records on a date which is string stored in the database.e.g
Table 1
 
IRN       Note
68360  27/02/2006
68362  16/12/2005
68486  15/04/2005
68488  20/04/2005
68490  16/06/2005
68493  18/04/2005
68495  14/06/2005
68496  21/04/2005
 
Table 2
 
IRN        NOTE
68488  Open
68490  Until revised
68496  Open
68498  Open
68500  Open
68708  Open
68710  Open
68712  Open
68714  Open
68716  Open
68742  21/08/08
68749  Open
68751  Open
68767  Open
68769  Open
68971  Open
92025  Open
92061  03/12/2006
92367  Open
92373  14/05/2007
92715  Open
92728  Open
93090  Open
93100  Open
93121  Open
93802  Continuing
 
 
The NOTE field is nvarchar. Do I need to convert to date type?
This report is going to select records based on Table 1 and table 2
where table2's Note field has to be converted from OPEN to '31/12/2050' first before being selected by report, is it achievable?
 
In my record selection I have used:
if {NL6.NOTE} = 'OPEN' then
   {NL6.NOTE} = '31/12/2050' and
{NL5.NOTE} >= {?Start Expiray Date} and
{NL6.NOTE} <= {?End Expiray Date}
the {?Start Expiray Date} and {?End Expiray Date}  are string type parameters
But it didn't work, could somebody please advise? Thanks in advance.
 
John
 


Edited by johnwsun - 08 May 2009 at 11:38pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 May 2009 at 8:18am
Use a formula to change the field to a date type then use the formula field in your select statement.
Make sure your formula conversion handles all the text options or it will choke on it when it hits one like "68490  Until revised".
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 18 May 2009 at 5:15am
Thank you, DBlank.
Unfortunately, firstly  the Table 1 contains lots of other values except 'xx/xx/xxxx', secondly, as you indicated it will fail when it hits Until revised".Until revised", 'continuing', $1000, etc. I might not be able to create a formula to handle anything like these.
Hence I make this report select based on table2.NOTE = 'Open' and table1.NOTE <> NULL.
I was thinking to creating a view on SQL server to filter out values other than 'xx/xx/xxxx' in table 1( it will drop out many associated records in a sense), but table 2 wouldn't be possible.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 May 2009 at 6:29am
Hey John,
Since I am not sure what you are wanting to include or exclude I am hesitant to try and write the formula but I think you can take care of much of what you need by using the isdate function. It will return a true or false for for each record if it is a date field or not.
Let me know if you need any help.
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 24 May 2009 at 4:30am
Thanks, DBlank,
 
I have advised to the customer that I am not going to select records based on these two tables, one of the reason that if I may be able to filter out some garbage, and the user will still keep keying garbage, and the reports will fail. As a result I make this report where Table1.NOTE <> "" and Table2.NOTE <> ""
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