Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Comparing Oracle Date Time column to Crystal Date Post Reply Post New Topic
Author Message
cruser2
Newbie
Newbie


Joined: 07 Feb 2012
Online Status: Offline
Posts: 14
Quote cruser2 Replybullet Topic: Comparing Oracle Date Time column to Crystal Date
     Posted: 08 Oct 2012 at 5:29am

Hi, there is some code in a formula that compares a date time column to a date parm in Crystal.  It works ok if the date time column has a zero time portion but does not if there is a time (which most of the columns do).

The code is:

   {Command.STMOD_HIST_DATE} in {?Reg Date From} to {?Reg Date To} then

So ?Reg Date From and ?Reg Date To = 2012-5-30

So for a STMOD_HIST_DATE = 30/05/2012 00:00:00 it picks it up ok, but

For STMOD_HIST_DATE = 30/05/2012 15:33:00 it dosent.

I did try to change the parm to a date time but it is so embedded in the report it pretty much wipes it out.

So how can I change the {Command.STMOD_HIST_DATE} expression just to compare the date portion?

Thanks,

JD.

IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 08 Oct 2012 at 6:56am
You should be able to do a date({Command.STMOD_HIST_DATE}) to strip off the time.

I hope this helps.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 09 Oct 2012 at 10:13am
Kevlray is correct. However, if you're using this comparison in the Selection Criteria, the use of the Crystal Date() function will cause Crystal to bring all of the data into memory and do the filter there instead of having the database do the filtering. This can cause reports to run much more slowly. If this is an issue, you need to use the Oracle trunc() function on the date.
Since this data appears to be returned in a command, I would add the parameter to the command like this:
1. Remove the parameter from the report! This is important - parameters used by commands have some additional "hidden" properties and need to be created in the Command Editor.
2. Edit your command.
3. Define the two parameters in the Command Editor.
4. Add something like the following to the "Where" clause in your command:
trunc(MyTable.STMOD_HIST_DATE) between {?Reg Date From} and {?Reg Date To}
This will force the filter to the database, making your report much faster.
-Dell
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