There is a datetime field in the MySQL table:
`mytime` datetime
It contains entries like '2012-02-10 10:15'.
How to set the date part to the current date?
In the Date and time dialog box, select the format you want. Select the Update automatically check box. The date is inserted as a field and will update automatically.
To update with the current date and time: UPDATE table_name SET date_field = CURRENT_TIMESTAMP; To update with a specific date value: UPDATE table_name SET date_field = 'YYYY-MM-DD HH:MM:SS.
In general just use now() to set a datetime column with the current date AND time. Whether an insert, update or trigger it doesn't matter. Several answers here have updates without a where clause. Most updates would have a where clause so as not to affect the whole table.
With the help of CURDATE() and NOW() function, we can insert current date automatically in a column of MySQL table.
You can use -
update table tblName set mytime = current_date()
Or
update table tblName set mytime =concat(current_date(),' ',TIME(mytime))
Use below query..
update Table1 set mytime=now();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With