PredicateExpression on Date Part

Posts   
 
    
AJPT
User
Posts: 15
Joined: 10-Jul-2013
# Posted on: 07-Aug-2013 19:40:16   

Hi - I want to be able to filter on dates which have a certain day. In SQL i would just use DATEPART, so how can this be achieved in LLBLGen selfservicingusing PredicateExpression?

e.g.

filter.Add(InvoiceFields.Date.<something to say get the day of month> == 20);

I was thinking perhaps there's a way to either specify a SQL function to wrap around the value, or perhaps a way (hacky) to append T-SQL to the predicate?

How can I achieve what I want here?

AJPT
User
Posts: 15
Joined: 10-Jul-2013
# Posted on: 07-Aug-2013 20:30:50   

It's ok I have the answer:

var f = InvoiceFields.DueDate; f.ExpressionToApply = new DbFunctionCall("CAST({0} AS int)", new object[] { new DbFunctionCall("DAY", new object[] { InvoiceFields.DueDate }) }); filter.Add(f == 10);