在写一段查询语句时,需要判定结束日期是不是大于当前日期,一般情况下都是通过php判定日期,然后进行日期查询。

php中得到判定日期的sql日期查询语句:

代码示例:

$now = time(); //获取当期的日期

$sql="select * from `team` where end_time>$now ORDER BY sort_order limit 0,4";

获取当前时间的MySql时间查询函数。

处理MySql时间日期的函数有很多,以下介绍用于获取当前时间的MySql时间函数。

MySql时间函数用于获取当前时间,该MySql时间函数极具实用价值。

代码示例:

mysql> select current_timestamp();

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

| current_timestamp() |

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

| 2010-01-18 21:24:37 |

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

1 row in set (0.00 sec)

mysql> select current_date();

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

| current_date() |

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

| 2010-01-18 |

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

1 row in set (0.00 sec)

mysql> select current_time();

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

| current_time() |

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

| 21:24:46 |

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

1 row in set (0.00 sec)