gpt4 book ai didi

mysql - sql函数将分钟: seconds ,数百转换为秒

转载 作者:行者123 更新时间:2023-11-29 13:49:55 25 4
gpt4 key购买 nike

如何将 SELECT 语句的 WHERE 子句中存储的值(如 01:14,12)转换为秒(如 74,12)?

我正在使用mysql

该列是 char(10) 但我可以更改它。

最佳答案

尝试:

select total_seconds =DATEDIFF(second,0,'20:10:10');

DATEDIFF 应该可以解决您的问题。

Here you can check DATEDIFF

所以只需输入:

WHERE DATEDIFF(second,'00:00:00',your_column) blablabla the comparisson you want

对于 MySQL 有一个函数:

TIME_TO_SEC(time)

将时间“01:14:12”转换为秒。

TIME_TO_SEC(时间)

Returns the time argument, converted to seconds.

mysql> SELECT TIME_TO_SEC('22:23:00');
-> 80580
mysql> SELECT TIME_TO_SEC('00:39:38');
-> 2378

关于mysql - sql函数将分钟: seconds ,数百转换为秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16837826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com