DateTime difference in seconds

Posts   
 
    
dannyyy
User
Posts: 5
Joined: 07-Feb-2011
# Posted on: 07-Feb-2011 12:10:06   

Hi all,

In LinqToSql from Microsoft we've used the following statement to get the difference of two timestamps in seconds:

Where(s => SqlMethods.DateDiffSecond(s.LastUpdate, DateTime.Now) <= SessionTimeout)

How has the query to look likes with LLBLGEN Pro? Important is to filter on server side and not in memory.

Kind regards, Danny

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Feb-2011 15:13:05   

You can use DateTime.AddSeconds() or .CompareTo() as follows:

I'm using AddYears() in the following example.

                var q = from o in metaData.Order
                        where o.OrderDate.Value.AddYears(14) > DateTime.Now
                        select o;

This Translates into Sql Server method DateAdd(), or DateDiff().

For more info please check Function mappings