MINUTE()
函数说明
返回 time 的分钟,取值范围为 0 到 59,如果 time 为 NULL 则返回 NULL。
函数语法
1. > MINUTE(time)
参数释义
| 参数 | 说明 |
|---|---|
| time | 必要参数。表示时间或时间戳的值。 |
示例
- 示例 1:
1. mysql> SELECT MINUTE('2008-02-03 10:05:03');
2. +-----------------------------+
3. | minute(2008-02-03 10:05:03) |
4. +-----------------------------+
5. | 5 |
6. +-----------------------------+
7. 1 row in set (0.00 sec)
- 示例 2:
1. drop table if exists t1;
2. create table t1(a datetime, b timestamp);
3. insert into t1 values("2022-07-01", "2011-01-31 12:00:00");
4. insert into t1 values("2011-01-31 12:32:11", "1979-10-22");
5. insert into t1 values(NULL, "2022-08-01 23:10:11");
6. insert into t1 values("2011-01-31", NULL);
7. insert into t1 values("2022-06-01 14:11:09","2022-07-01 00:00:00");
8. insert into t1 values("2022-12-31","2011-01-31 12:00:00");
9. insert into t1 values("2022-06-12","2022-07-01 00:00:00");
11. mysql> select minute(a),minute(b) from t1;
12. +-----------+-----------+
13. | minute(a) | minute(b) |
14. +-----------+-----------+
15. | 0 | 0 |
16. | 32 | 0 |
17. | NULL | 10 |
18. | 0 | NULL |
19. | 11 | 0 |
20. | 0 | 0 |
21. | 0 | 0 |
22. +-----------+-----------+
23. 7 rows in set (0.00 sec)
25. mysql> select * from t1 where minute(a)<=minute(b);
26. +---------------------+---------------------+
27. | a | b |
28. +---------------------+---------------------+
29. | 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |
30. | 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |
31. | 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |
32. +---------------------+---------------------+
33. 3 rows in set (0.00 sec)
