mysql 时间 删除,MYSQL日期时间,删除秒

I've been attempting to do this for quite sometime.

I have a program which periodically writes rows to a table.

(table1)

ID Date Text Number

The Date column is in format yyyy-mm-dd hh:mm:ss ("2013-08-03 06:26:27")

The script which reads the data matches it to another set of data with the date in the same format except that the seconds are exactly 0.

"2013-08-03 06:26:00"

I need to change the Date data column in (Table 1) so that the seconds column is exactly zero. Currently it is just random values.

I have changed it on script level so that it writes the data to the MYSQL table so that the seconds is 0. However I have a lot of existing data which I can not loose which does not have the seconds at 0.

解决方案

This is just a matter of updating the corresponding column.

Depending on ... hum ... your mood (?) you might try:

update tbl set datetime_column = substr(datetime_column, 1, 16);

Or

update tbl set datetime_column = date_format(datetime_column, '%Y-%m-%d %H:%i:00');

Or

update tbl set datetime_column = datetime_column - second(datetime_column);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值