简单方法:
使用 days
字符型的日期:2012-01-01,2012-01-11
values days(date('2012-01-11')) - days(date('2012-01-01'))
----------------------------
10
错误示例:
//sql.Append(" LEFT JOIN (SELECT COUNT(1) AS QTY , R.FRAMENO FROM RT_REPAIR R WHERE CURRENT DATE -DATE(R.STATUSCODEDATE10) <=365 AND STATUSCODE='99' GROUP BY R.FRAMENO) T10 ON T1.FRAMENO = T10.FRAMENO ");
sql.Append(" LEFT JOIN (SELECT COUNT(1) AS QTY , R.FRAMENO FROM RT_REPAIR R WHERE (DAYS(CURRENT DATE) -DAYS(R.STATUSCODEDATE10)) <=365 AND STATUSCODE='99' GROUP BY R.FRAMENO) T10 ON T1.FRAMENO = T10.FRAMENO ");