I have the datetime format in my Mysql table such as this, on my_date column.
0000-00-00 00:00:00
which will be populated with year, month, day, and time, from [SELECT]'s, with the onBlur Javascript function.
I need to update, at any time, only one value of the datetime above.
So when I will trigger the year SELECT, it will change the year in the database. When I trigger the month, it will modify the month.
I've searched around and could not find any relevant answer. Thanks!
CodePudding user response:
I have used the first suggestion in the comments, which is to set the full date in my selects (year, month, day, and time), and then use a simple [BUTTON] with onClick -> call to an AJAX that would save the whole date once.
Thanks all!
CodePudding user response:
You can use trick with date_format function for change part of datetime filed like:
-- change year
update tbl set d = date_format(d, '2020-%m-%d %H:%i:%S');
-- change month
update tbl set d = date_format(d, '%Y-03-%d %H:%i:%S');