Hello,
I am attempting to usethe following code to count the number of bookings stored in my table since last Monday. I have a datetime collumn (c_lastcalled) anda function that gives me the correct date of the previous Mondaybut I cannot get the query to return the correct count value. In my test dataset I know there are 4 records that will match this query today but continue to get a count value of 0. Here is the code:
DateTime bookingsLimit = getLastMonday(DateTime.Today);
/* Gets the date of the last monday from today (or today if it is Monday!) */
sqlComm = new SQLiteCommand("SELECT COUNT(Calls.id) AS bookingsMade FROM Calls WHERE Calls.c_status = 2 AND DATE(c_lastcall) >= DATE(@lookfor)", sqlConn);
SQLiteParameter paramDate = new SQLiteParameter("@lookfor");
sqlComm.Parameters.Add(paramDate);
paramDate.Value = bookingsLimit.ToShortDateString();
sqlConn.Open();
numBookings = Convert.ToInt32(sqlComm.ExecuteScalar());
sqlConn.Close();
sqlComm.Dispose();
Can anyone assist me in seeing why this query fails or advise me of a better way to write these type of date based queries? My locale (incase it matters) is en_gb (United Kingdom).
Thanks Again,
Mark Young
tip2tail
http://www.tip2tail.co.uk
Application Development (C#.NET), Web Development (PHP, MySql, ASP.NET, jQuery), IT Support
Hamilton, Scotland