2024年3月20日发(作者:)

20.

21.

22.

23.

24.

25.

26.

27.

28.

29.

30.

31.

32.

33.

34.

35.

36.

37.

38.

39.

40.

41.

42.

+----------------------------------------+

1 row in set (0.00 sec)

MySQL> select date_sub(current_timestamp, interval 1 day);

+---------------------------------------------+

| date_sub(current_timestamp, interval 1 day) |

+---------------------------------------------+

| 2010-01-17 21:28:41 |

+---------------------------------------------+

1 row in set (0.00 sec)

MySQL> select date_sub(current_date, interval 1 day);

+----------------------------------------+

| date_sub(current_date, interval 1 day) |

+----------------------------------------+

| 2010-01-17 |

+----------------------------------------+

1 row in set (0.00 sec)

MySQL> select date_sub(current_time, interval 1 day);

+----------------------------------------+

| date_sub(current_time, interval 1 day) |

+----------------------------------------+

| NULL |

+----------------------------------------+

1 row in set, 1 warning (0.00 sec)

MySQL Date函数 4、时间间隔

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

MySQL Date函数 5、时间转换

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

以上的相关内容就是对MySQL Date函数的介绍,望你能有所收获。

MySQL> select time_to_sec('25:00:00');

+-------------------------+

| time_to_sec('25:00:00') |

+-------------------------+

| 90000 |

+-------------------------+

1 row in set (0.00 sec)

MySQL> select sec_to_time(90000);

+--------------------+

| sec_to_time(90000) |

+--------------------+

| 25:00:00 |

+--------------------+

1 row in set (0.00 sec)

MySQL> select datediff('2010-01-18','2010-01-17');

+-------------------------------------+

| datediff('2010-01-18','2010-01-17') |

+-------------------------------------+

| 1 |

+-------------------------------------+

1 row in set (0.00 sec)

MySQL> select timediff('2010-01-18 12:00','2010-01-17 11:00');

+-------------------------------------------------+

| timediff('2010-01-18 12:00','2010-01-17 11:00') |

+-------------------------------------------------+

| 25:00:00 |

+-------------------------------------------------+

1 row in set (0.00 sec)