0
Date
2014-12-01 10:52:38
2014-12-01 10:52:14
2014-12-01 10:51:57
2014-12-01 10:35:34
2014-12-01 10:23:17
2014-12-01 10:22:18
2014-12-01 09:03:49
2014-12-01 08:53:51
I have this column with these dates and I need to select it as follows: send PARAMETRO DOM aaaaMMDdd with value already specified and I want the routine to bring me only the dates of a day. The difficulty is that the column is in the format yyyy-MM-dd HH:mm:ss and the select below does not bring me anything. How to do? Grateful
I am working with c# winform and MYSQL. att Marcos
static public string SelectQuantidadeRenavan(MySqlConnection db, string renavam,string datarecebe)
{
string strdata = Convert.ToDateTime(datarecebe).ToString("yyyy-MM-dd");
StringBuilder selectQuantidadeRenavam = new StringBuilder();
selectQuantidadeRenavam.AppendFormat("select count(RENAVAM)");
selectQuantidadeRenavam.AppendFormat(" from numtermo ");
selectQuantidadeRenavam.AppendFormat("WHERE ");
//selectQuantidadeRenavam.AppendFormat("RENAVAM = 1) {0}", renavam);
selectQuantidadeRenavam.AppendFormat("RENAVAM = {0} and Data = '{1}'", renavam, strdata)
MySqlCommand MysqlResult = new MySqlCommand(selectQuantidadeRenavam.ToString(), db);
return MysqlResult.ExecuteScalar().ToString();
}
Then Caffé, it rotated perfectly but in the table has two equal RENAVANS and the routine returned me only 1 value being that it should be two. What may have happened?
– Joelias Andrade
@Joeliasandrade I don’t know. Your query will always return only 1 record given that you used a COUNT. Is the amount of records or the value of COUNT not matching? Try updating your question with the complete records (you only entered the dates) and also stating the exact values (you can check by debugging the application) received in
renavam
anddatarecebe
.– Caffé
Sorry Caffé but yesterday everything went well your guidance.It was I who renamed a different date... Anyway, thank you very much.
– Joelias Andrade
How do I score VC?
– Joelias Andrade
@Joeliasandrade You can click the arrow icon above the left side of an answer or question to vote or the icon below the arrows, in answers to questions you have asked, to mark the answer as the accepted answer. When you mouse over the icons the description appears. See also: http://answall.com/tour
– Caffé