Comparing Dates

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 16-May-2005 16:47:15   

Hi,

How can I have a predicate which says - select where date is in the month of January?

Cheers,

Ian.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 16-May-2005 17:38:40   

Either: 1) add a calculated column to your table, and filter on that column or 2) create a special IPredicate implementation, by copying the FieldCompareFieldPredicate class sourcecode and modifying it into FieldCompareMonthPredicate.

Frans Bouma | Lead developer LLBLGen Pro
Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 16-May-2005 17:43:02   

Why wouldn't a between work?


DateTime startDate = new DateTime(2005,0, 1);
DateTime endDate = startDate.AddMonths(1).AddSeconds(-1);

IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add( PredicateFactory.Between(FooFieldIndex.TimeStamp, startDate, endDate) );

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 16-May-2005 17:44:04   

Cadmium wrote:

Why wouldn't a between work?


DateTime startDate = new DateTime(2005,0, 1);
DateTime endDate = startDate.AddMonths(1).AddSeconds(-1);

IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add( PredicateFactory.Between(FooFieldIndex.TimeStamp, startDate, endDate) );

I thought of that, but it might be he wants to have all values of all the years simple_smile If not, a between will work indeed! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 16-May-2005 18:24:52   

I suppose I could add a between for all years within a 200 year span.

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 16-May-2005 18:44:06   

In fact, a 'for' loop for the next 5 years would probably suffice. That would give me enough time to get round to creating a custom IPredicate. smile

Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 16-May-2005 21:15:40   

Otis wrote:

I thought of that, but it might be he wants to have all values of all the years simple_smile If not, a between will work indeed! simple_smile

Oh, I see now. Right, yeah that would be a bit more difficult simple_smile