修改日期前缀年月日,后缀时分秒不变
修改日期前缀年月日,后缀时分秒不变
-- 修改日期date前缀指定日期年月日2023-01-10,后缀时分秒不变 update table_name set date = STR_TO_DATE(concat('2023-01-10',DATE_FORMAT(date,' %T')),'%Y-%m-%d %T') -- 修改日期date前缀为当天日期年月日2023-01-11,后缀时分秒不变 update table_name set date = STR_TO_DATE(concat(SUBSTR(SYSDATE(),1,10),DATE_FORMAT(date,' %T')),'%Y-%m-%d %T')
修改日期年月日时分秒
-- 修改日期date前缀指定日期年月日时2023-01-10,后缀分秒不变
update table_name set date = STR_TO_DATE(ADDTIME(DATE('2023-01-10') + INTERVAL -10 HOUR, DATE_FORMAT(date,' %T')),'%Y-%m-%d %T')
-- 修改日期date前缀指定日期年月日时分2023-01-10,后缀秒不变
update table_name set date = STR_TO_DATE(ADDTIME(DATE('2023-01-10') + INTERVAL -10 MINUTE, DATE_FORMAT(date,' %T')),'%Y-%m-%d %T')
-- 修改日期date前缀指定日期年月日时分秒2023-01-10
update table_name set date = STR_TO_DATE(ADDTIME(DATE('2023-01-10') + INTERVAL -10 SECOND, DATE_FORMAT(date,' %T')),'%Y-%m-%d %T')
查询某个日期年月日,拼接当前时间+10的时分秒
select ADDTIME(DATE('2023-01-10') + INTERVAL 10 HOUR,TIME(SYSDATE())) as date;
select ADDTIME(DATE('2023-01-10') + INTERVAL 10 MINUTE,TIME(SYSDATE())) as date;
select ADDTIME(DATE('2023-01-10') + INTERVAL 10 SECOND,TIME(SYSDATE())) as date;