如果我有几条时间戳记录并且想要获取最接近当前日期的时间戳。我应该使用什么确切的查询命令?提前致谢。下面我描述了我的最后一个查询命令:
mysql> select date_format(time_stamp, '%Y-%m-%d %H:%i:%s' ) as Time_Stamp
from log
where username='test' and Time_Stamp <= NOW();
| 2012-11-23 14:50:28 |
| 2012-11-23 16:39:45 |
| 2012-11-23 16:51:41 |
| 2012-11-23 16:58:43 |
| 2012-11-25 10:12:14 |
| 2012-11-25 12:50:38 |
| 2012-11-25 12:51:20 |
| 2012-11-25 13:15:44 |
| 2012-11-25 17:47:43 |
| 2012-11-26 09:24:46 |
+---------------------+
285 rows in set (0.00 sec)
我只想得到2012-11-26 09:24:46