I am using C# to run SQL and want to only pull in data from that day. Below is my code that I am using, but it isn't returning anyr esults, but I know it should. Makes me think that I have my day function set-up incorrectly.
string SQLQuery = "SELECT empName, empNumber, itemSold FROM store106data Where DateofSale = @DOS;" SqlConnection connection = newSqlConnection("Connection String is here"); SqlCommand cmd = new SqlCommand(SQLQuery, conn); //This is just a snippet not full on code, but will show the issue I am experiencing DayOfWeek day = DateTime.Today.DayofWeek; if (day == DayOfWeek.Tuesday) { DateTime now = DateTime.Now; string dt = now.GetDateTimeFormats('d')[0]; cmd.Parameters.AddWitValue("@DOS", dt.ToString()); }
edit ---
This is returning 6/25/2013 but my database houses 06/25/2013 is that the issue? and if so, how would I set my code to return the leading 0?