Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
选择不同的时间戳作为DD/MM/YYYY mysql_Mysql_Sql - Fatal编程技术网

选择不同的时间戳作为DD/MM/YYYY mysql

选择不同的时间戳作为DD/MM/YYYY mysql,mysql,sql,Mysql,Sql,我有多行用于itemDate(时间戳),如下所示: itemDate 2013-04-09 17:24:31 2013-04-09 10:24:31 2013-04-08 12:20:30 当我使用时,从item中选择DISTINCT(itemDate),我得到了2013-04-08的两行 我想获取不同日期的日期(基于YYYY-MM-DD),忽略同一天的时间是否不同 当我从该表查询时,我需要的结果应该如下所示: itemDate 2013-04-09 2013-04-08 这是因为这些值是不

我有多行用于
itemDate
(时间戳),如下所示:

itemDate
2013-04-09 17:24:31
2013-04-09 10:24:31
2013-04-08 12:20:30
当我使用
时,从item中选择DISTINCT(itemDate),我得到了2013-04-08的两行

我想获取不同日期的日期(基于
YYYY-MM-DD
),忽略同一天的时间是否不同

当我从该表查询时,我需要的结果应该如下所示:

itemDate
2013-04-09
2013-04-08

这是因为这些值是不同的。如果要按日期执行此操作,请使用以下函数:

SELECT DISTINCT(DATE(itemDate)) FROM item;

另一个答案的替代方法是使用
DATE\u FORMAT()


在我这方面,我尝试了上面建议的不同选项,但我使用的Sybase DB拒绝了我:

Error: Function 'DATE' not found. If this is a SQLJ function or SQL function, use sp_help to check whether the object exists (sp_help may produce a large amount of output).
我的同事给了我这个,效果很好

SELECT distinct(CONVERT(varchar(20), timestamp, 111)) FROM HistoOrder
我使用111,但你们可以在这里找到代码列表

itemDate的列类型是什么?在spring JPA查询方法中有没有办法做到这一点?
SELECT distinct(CONVERT(varchar(20), timestamp, 111)) FROM HistoOrder