Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Record Selection Formula Post Reply Post New Topic
Author Message
BethanyDunlap
Newbie
Newbie
Avatar

Joined: 29 Nov 2012
Location: United States
Online Status: Offline
Posts: 2
Quote BethanyDunlap Replybullet Topic: Record Selection Formula
     Posted: 07 Jan 2013 at 3:43am
Hello,

I have used a report for all of 2012 and it seemed to work correctly. Now all of a sudden, it is not. The issue is my Record Selection Formula, I believe. I created two date parameters and am comparing them to a date associated with the record. When I run it for 1/1/2013 - 1/6/2013, it grabs records from 1/1/2012 - 1/6/2012 and 1/1/2013 - 1/6/2013. As I mentioned, I used it last year and it never grabbed records from 2011. Why would it do this now? log1.date is a string in the database and my parameters are dates. Please help! Here is my record selection:

{security_log1.date}   >=   CStr ({?Minimum_Date}, "MM/dd/yyyy")
and
{security_log1.date}   <=   CStr ({?Maximum_Date}, "MM/dd/yyyy")
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 08 Jan 2013 at 2:43am
Hi

There no issue with the formula,

can you place {?Minimum_Date) and Maximum_Date parameters to your report header and see what values it is returning ?


Thanks,
Sastry
IP IP Logged
BethanyDunlap
Newbie
Newbie
Avatar

Joined: 29 Nov 2012
Location: United States
Online Status: Offline
Posts: 2
Quote BethanyDunlap Replybullet Posted: 08 Jan 2013 at 2:55am
Yes. I did that and it does return the date parameters in date format. I posted on another forum and someone gave me different code that works. It was:
Date({security_log1.date}) in [{?Minimum_Date} to {?Maximum_Date}]

I just don't see why the original code is grabbing records from the year prior and the year it is run for.

My date in the database is a string and in MM/dd/yyyy format just as my parameters in the record selection.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Jan 2013 at 7:23am
I do not like to use < or > on strings as I do not think that they evaluate in the way that you desire, especially on dates.
I am guessing that it appeared to work for you this past year because your data source had no records with any Jan dates of a 2011 or less.
 
To see how the "calendar" strings functions grab a DB with multiple years  of data in it and convert the date to your "MM/dd/yyyy" string and sort on that string. You will see the sort not even close to a calendar day sort.
Add another formula as a using your > and < comparison and you will see the multiple years on those dates be included.
In general, if you want to do date comparisons try to use the actual date field type or convert them to YYYYMMDD
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