MYSQL日期时间,删除秒 [英] MYSQL Datetime, remove seconds

查看:638
本文介绍了MYSQL日期时间,删除秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了一段时间了.

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

我有一个定期向表中写入行的程序.
(表格1) ID日期文本编号

I have a program which periodically writes rows to a table.
(table1) ID Date Text Number

日期"列的格式为yyyy-mm-dd hh:mm:ss("2013-08-03 06:26:27")

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

读取数据的脚本将其与日期与日期相同的另一组数据相匹配,只是秒数完全为0.

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"

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

我需要更改(表1)中的日期"数据列,以使秒列完全为零.目前,它只是随机值.

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.

我已在脚本级别对其进行了更改,以便将数据写入MYSQL表,以使秒为0.但是,我有很多现有数据,这些数据我无法松散,并且秒数都不为0./p>

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);

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

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

这篇关于MYSQL日期时间,删除秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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