MySQL DATETIME-仅更改日期 [英] MySQL DATETIME - Change only the date

查看:55
本文介绍了MySQL DATETIME-仅更改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从开始:2011-01-17 09:30:00

Starting with : 2011-01-17 09:30:00

假设我只想编辑2011-01-28的日期

Let's say I want to edit just the date with 2011-01-28

最有效的结局是:2011-01-28 09:30:00

What is the most efficient way to end up with: 2011-01-28 09:30:00

谢谢!

对于每个说Date_Add ...的人,这都需要我减去日期,然后加上日期.那是有可能的……但它正打算删除该第一步,而只是替换"日期

For everyone saying Date_Add... that would require me to subtract the dates, then add the days. Thats a possibility... but was looking to remove that first step, and just "replace" the date

推荐答案

如果您真的不想使用date_add函数,则可以考虑使用以下结构:

If you really don't want to use date_add function, you can consider using this construction:

UPDATE table_name SET field_name = concat('2011-01-12 ', time(field_name)) 

请确保在日期之后添加一个空格('2011-01-12 ').

Make sure to add a space after the date ('2011-01-12').

这篇关于MySQL DATETIME-仅更改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆