In this article, we will discuss about: minute(), microsecond(), and hour() MySQL functions. We will do these with the help of their syntax, usage and use cases.
MySQL是一个开源的关系型数据库管理系统。它允许用户存储和操作数据。在MySQL中,我们可以使用函数执行特定的任务。
The MINUTE() function returns the minute portion of a given time or datetime value. It takes one argument, which is the time or datetime value to extract the minutes.
Output range is 0 to 59 as integer value.
The syntax of the MINUTE() function is as follows
MINUTE(datetime)
SELECT MINUTE(NOW());
The output will be a single number. It represents the current minute value.
SELECT MINUTE("2023-04-02 13:06:07");
输出将是分钟值,这里是06。
SELECT MINUTE("13:06:07");
输出将是分钟值,这里是06。
MINUTE()函数可用于计算两个事件之间的时间长度。它可以设置特定时间戳的分钟值。
The MICROSECOND() function returns the microsecond portion of a given time or datetime value. It takes one argument, which is the time or datetime value to extract the microsecond.
Output range is 0 to 999999 as integer value.
The syntax of the MICROSECOND() function is as follows
MICROSECOND(datetime)
SELECT MICROSECOND(NOW());
输出将是一个单独的数字。它代表当前微秒值。
SELECT MICROSECOND("2023-04-02 13:06:07.000005");
The output will be microsecond value which is 05 here.
SELECT MICROSECOND("13:06:07.568549");
输出将是微秒值,这里是568549。
The MICROSECOND() function can be useful in scenarios where high precision is required.
HOUR()函数返回给定时间或日期时间值的小时部分。它接受一个参数,该参数是要提取小时的时间或日期时间值。
输出范围为0到23的整数值。
The syntax of the HOUR() function is as follows
HOUR(datetime)
SELECT HOUR(NOW());
输出将是一个单一的数字。它代表当前的小时值。
SELECT HOUR("2023-04-02 13:06:07.000005");
The output will be minute value which is 13 here.
SELECT MICROSECOND("13:06:07.568549");
The output will be minute value which is 13 here.
HOUR()函数在需要从时间戳中提取小时值的场景中非常有用。
我们已经讨论了这三个MySQL函数。这些函数用于处理时间或日期时间值。它们都只接受一个参数,即时间或日期时间。它们都返回一个整数值。
以上是MySQL 中的 MINUTE()、MICROSECOND() 和 HOUR() 函数的详细内容。更多信息请关注PHP中文网其他相关文章!