tags:

views:

60

answers:

1

I haven't found a clear answer but I would like to grab any values from within the past 24 hours. I have an alternative solution in code but I would like to see if there is an equivalent to using t-sql datediff

+2  A: 

You don't need datediff, because you already know what time it was 24hs ago.

Here's a Linq (NH 3.x) example:

session.Query<Foo>()
       .Where(f => f.DateAndTime >= DateTime.Now.AddDays(-1))

If you use HQL, you can get the DB server time with standard functions like current_timestamp (left as an exercise, but I'll add that if you need it)

Diego Mijelshon