Between Predicate

Posts   
 
    
Posts: 35
Joined: 22-May-2006
# Posted on: 26-Jul-2006 18:27:31   

Hi,

I have a question in regards to the Between predicate. What i am seeing is that if you select two dates, 7/9/2006 and 7/11/2006 that the only records with the date 7/10/2006 will come back. I want to have it include all the records that occur on the start date, end on the start date and all records between the two.

Here is what i currently have:


filter.Add(PredicateFactory.Between(SecurityFingerprintFieldIndex.SecFpCreateDate, FPCreateDateStart, FPCreateDateEnd));

Any suggestions would be appreciated.

Thanks,

Nate

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 26-Jul-2006 18:31:12   

A betweenPredicate memics or generates the database Between operator. So you better use 2 compare value predicates with >= or <= used.

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 26-Jul-2006 19:04:05   

and beware of the times at the end of the range.

By default, between will look < EndDate at 00:00

Not EndDate at 23:59:59

therefore you will miss everything that happened on EndDate.

Posts: 35
Joined: 22-May-2006
# Posted on: 26-Jul-2006 21:30:12   

Thanks for the information. Upon further investigation I found that the start date would be 7/1/06 12:00 AM and the end date would be 7/5/06 12:00 AM. The between predicate would retrieve all of the items on 7/1/06 since it started at 12:00 AM, the beginning of the day but none on the end date. I like to use the between simply to the simplicity (albeit it is one line of code less), but to over come the end date i simply added 24 hours to it. Since all of the dates are simply dates with no user provided times (so it will default to 12:00 AM) I am in the clear on that.

Thanks again for your help.