Does SubSonic.SqlQuery have a between/and for date ranges? If not, what would be the best way to get a range.
+3
A:
Try something like this:
SqlQuery query = new SqlQuery().From("Table")
.WhereExpression("Column")
.IsBetweenAnd("1/1/2008", "12/31/2008");
DataSet dataSet = query.ExecuteDataSet(); // Or whatever output you need
Forgotten Semicolon
2008-10-03 00:31:17
Here's another snippet.. which ended up being my solution...And(Order.OrderDateColumn).IsBetweenAnd(lastRunDate,System.DateTime.Now);
madcolor
2008-10-03 14:47:07
Glad it worked for you.
Forgotten Semicolon
2008-10-03 14:48:47
A:
Combined Northwind answer:
SqlQuery query = new SqlQuery().From("Orders")
.WhereExpression("OrderDate")
.IsBetweenAnd("1996-07-02", "1996-07-08");
DataSet dataSet = query.ExecuteDataSet(); // Or whatever output you need
#region PresentResultsReplaceResponseWriteWithConsole.WriteLineForConsoleApp
DataTable dt = dataSet.Tables[0];
Response.Write("<table>");
foreach ( DataRow dr in dt.Rows )
{
Response.Write("<tr>");
for (int i = 0; i < dt.Columns.Count; i++)
{
Response.Write("<td>");
Response.Write(dr[i].ToString() + " ");
Response.Write("<td>");
} //eof for
Response.Write("</br>");
Response.Write("</tr>");
}
Response.Write("<table>");
#endregion PresentResultsReplaceResponseWriteWithConsole.WriteLineForConsoleApp
YordanGeorgiev
2009-06-02 18:27:31