我在MySQL表中有一个列日期,日期如 -
01/01/2014
02/01/2014
05/01/2014
06/01/2014
25/04/2014
26/04/2014
27/04/2014
28/04/2014
29/09/2014
30/09/2014
01/10/2014
我需要选择开始日期和结束日期,这些日期之间至少有30天的差异,例如我将得到的日期
Starting Date - Ending Date
01/01/2014 - 06/01/2014
25/04/2014 - 28/04/2014
29/09/2014 - 01/10/2014
如何在MySQL选择查询中执行此操作?
由于
答案 0 :(得分:-1)
SELECT A.DateVal AS StartDate,B.DateVal AS EndDate FROM TableName AS A,TableName AS B WHERE DATEDIFF(A.DateVal,B.DateVal)> = 30