tags:

views:

150

answers:

2

How do I write this SQL statement with Subsonic 2.2 Query Object?

SELECT * FROM Product
WHERE DateDiff(d, StartDate, GetDate()) >= 0 
AND DateDiff(d, EndDate, GetDate()) <= 0
A: 

Either use a stored procedure or InlineQuery object.

John Sheehan
I think this would be the fastest way to achieve my goal.
+1  A: 

You could do this another way if all your trying to achieve is make sure that a value is between two dates or greater than one and the other.

you'll just have to take the date calculation into the .net realm and feed it into your query using either

.Between()

or

    .AndExpression(Products.Columns.DateField).IsGreaterThan(X)
    .And((Products.Columns.DateField).IsLessThan(X)
Doug