在mysql中只获取时间戳的日期 [英] Get only the date in timestamp in mysql
本文介绍了在mysql中只获取时间戳的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的数据库的t_stamp列下,我有日期例如
On my database under the t_stamp columns I have the date for example
2013-11-26 01:24:34
从同一列我只想得到日期
From that same column I only want to get the date
2013-11-26
我这样做谢谢!
推荐答案
您可以使用 date(t_stamp)
获取只有日期部分来自时间戳。
You can use date(t_stamp)
to get only the date part from a timestamp.
您可以检查date()函数在文档
You can check the date() function in the docs
DATE (expr)
提取date或datetime表达式expr的日期部分。
Extracts the date part of the date or datetime expression expr.
mysql > SELECT DATE('2003-12-31 01:02:03');
- >'2003-12-31'
mysql> SELECT DATE('2003-12-31 01:02:03'); -> '2003-12-31'
这篇关于在mysql中只获取时间戳的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文