SELECT DATEDIFF(day,(SELECT creation_date
FROM time_info
WHERE is_on = 'yes'
LIMIT 0,1),
(SELECT creation_date
FROM time_info
WHERE is_on = 'no'
LIMIT 0,1)
FROM time_info;
我想计算日期差异,但事情并非如此。还有另一种方法吗?
答案 0 :(得分:0)
你的牙套'(',')'在SELECT语句中不平衡。
答案 1 :(得分:0)
试试这个
SELECT DATEDIFF(t1.creation_date,t2.creation_date )
FROM time_info t1
INNER JOIN time_info t2 ON t1.your_id_column = t2.your_id_column
WHERE t1.is_on = 'yes' AND t2.is_on = 'no';
答案 2 :(得分:0)
试试这个
set @date1:=(SELECT creation_date
FROM time_info
WHERE is_on = 'yes'
LIMIT 0,1);
set @date2:= (SELECT creation_date
FROM time_info
WHERE is_on = 'no'
LIMIT 0,1);
select datediff(@date1,@date2);
您需要提供更多信息才能了解您的目标