WHERE SomeDate <= GetUTCDate()

Posts   
 
    
sqlmatt
User
Posts: 3
Joined: 14-Aug-2007
# Posted on: 14-Sep-2007 21:25:08   

I am not finding how to accomplish this in a Predicate, other than using DateTime.Now.ToUniversalTime() instead of calling the DB function.

filter.Add(new FieldCompareValuePredicate(SomeTableFields.SomeDate, null, ComparisonOperator.LessEqual, DateTime.Now.ToUniversalTime()));

Is there a way to get the DB's GetUTCDate() function called?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Sep-2007 02:44:41   

Hi,

You can use LLBLGenPro _DBFunctionCall _feature (assuming you are using v2.0 or superior).

Your code should look like:

DbFunctionCall utcFunction = new DbFunctionCall("GetUTCDate", new object[] { });

filter.Add(SomeTableFields.SomeDate <= utcFunction);

Hope helpful simple_smile

David Elizondo | LLBLGen Support Team
sqlmatt
User
Posts: 3
Joined: 14-Aug-2007
# Posted on: 15-Sep-2007 03:40:40   

Perfect, thanks so much! I will try to spend more time in the documentation. smile