DB2 日期相减

简单方法:

使用 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 ");

上一篇:Refresh recovery area usage data after manually deleting files under recovery area


下一篇:VB.net数据库编程(03):一个SQLserver连接查询的简单样例