Page 1 of 1
Mysql added datetime
Posted: Sun 09 Nov 2014 01:47
by croc
When I sent this to a datetime field: date ''2014-11-09 12:08:43'' this will work. But what should I sent to take the server time of my mysql server?
Re: Mysql added datetime
Posted: Sun 09 Nov 2014 13:31
by croc
I would like to have the mysql server time if that is not possible sent the client time.
When I take the client time like this:
' + QuotedStr(Datetostr(Date) +' '+ timetostr(now))+ ' for instead of ''2014-11-09 12:08:43''
It doesn't work.
How can I fix this ??
Re: Mysql added datetime
Posted: Mon 10 Nov 2014 09:16
by ViktorV
To set client time in a SQL query, you can use the following code:
Code: Select all
QuotedStr(FormatDateTime('yyyy-mm-dd hh:mm:ss',Now))
To get the current time of a MySQL server, you can use the following SQL query:
Re: Mysql added datetime
Posted: Mon 10 Nov 2014 22:46
by croc
hmm maybe I am doing something wrong.
It doesn't work.
UniConnection1.ExecSQL('INSERT INTO `test` (`TEMP`, `DATE & TIME`) VALUES (''14.2C'', QuotedStr(Select Now()) );');
How to get the Select Now() to work ?
Re: Mysql added datetime
Posted: Tue 11 Nov 2014 08:16
by ViktorV
To solve the problem, please try using the following code:
Code: Select all
UniConnection1.ExecSQL('INSERT INTO test (`TEMP`, `DATE & TIME`) VALUES (''14.2C'', Now())');
Re: Mysql added datetime
Posted: Wed 12 Nov 2014 21:30
by croc
Thanks

this works.
Re: Mysql added datetime
Posted: Thu 13 Nov 2014 11:19
by ViktorV
It is good to see that the problem has been solved.
Feel free to contact us if you have any further questions.