Filter on todays date

Posts   
 
    
Stephan
User
Posts: 63
Joined: 16-Jan-2007
# Posted on: 02-Oct-2007 14:37:25   

I read some threads about this, but it is still not clear to me. How can I get all the records from a collection for today only. It is an .NET 1.1 application using LLBlGen 2.0

I read something about setting the time of the date to 0:0:0 and 23:59:59 right, but I don't see the picture how to do this.

Any help appreciated

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 02-Oct-2007 17:50:33   

Hi, this is what I do:

if (fromDate != DateTime.MinValue && hasta!= DateTime.MinValue)
{  bucket.PredicateExpression.Add(PredicateFactory.Between(OrdenFieldIndex.FechaExpiracionReserva, desde.Date, hasta.AddDays(1).Date));                 
}

notes: -"desde" y "hasta" are DateTime parameters passed to a method, I used the min values to know wheter the user wants to omit the date filter.

-bucket is a IRelationPredicateBucket.

-if you send desde y hasta with the same date, lets say DateTime.Now you'll obtain only the records of today.

Hope this was helpful,

Stephan
User
Posts: 63
Joined: 16-Jan-2007
# Posted on: 07-Oct-2007 12:10:54   

Hi Goose,

that is exactly how I did it too. Thanks for the reply

wink