簡體   English   中英

DateDiff不起作用

[英]DateDiff is not working

con = DriverManager.getConnection(Module.url, Module.username, Module.password);
String sql3 = "Update resume set DateDifference=DATEDIFF(End, Now())";
ps3 = con.prepareStatement(sql3);
ps3.executeUpdate();

在此處輸入圖片說明

End的數據類型為DATE,DateDifference為Varchar。 它不會更新數據庫中的表。 誰能幫我。

我嘗試在每行上使用System.out.println(“ Test1”)定位問題,僅打印至ps3 = con.prepareStatement(sql3); ps3.executeUpdate()出現問題;

我認為由於NULL值其未更新。

嘗試將datediff()函數轉換為char(50) 希望這可以幫助

con = DriverManager.getConnection(Module.url, Module.username, Module.password);
String sql3 = "Update resume set DateDifference=cast(DATEDIFF(End, Now()) as char(50))";
ps3 = con.prepareStatement(sql3);
ps3.executeUpdate();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM