I was trying to register using a query in c # the datetime.now
in a MySQL database
What I do in c # is:
cmd.CommandText = "INSERT INTO cola_llamadas(fecha,queueName,cola)" +
"VALUES(DATE_FORMAT('"+DateTime.Now+"', '%m/%d/%Y %H:%i'),'XXXX'," + Convert.ToInt32(subaux) +")";
cmd.ExecuteNonQuery();
The string of the query is apparently fine:
"INSERT INTO cola_llamadas(fecha,queueName,cola) VALUES(DATE_FORMAT('24/10/2017 16:35:03', '%m/%d/%Y %H:%i'),'XXXX',2)"
The problem is that I want to put it in a database with the format of
dd/mm/yyyy HH24:MI:SS
< --- I hope to explain myself with this. How can I convert the string? In SQL I would do it easily with To_Date, but in MySQL?
This is the error that returns me exactly:
#1292 - incorrect datetime value: '24/10/2017' 16:35:03'
It must be something very simple, but right now I do not fall and it's the first time I use MySQL as such.