如何在sql陳述句里使用datediff?
這是我的代碼:
string sql = "select No,Carno,Receivingunit,goods,Grossweight,Buckleweight," +
"Netweight,UnitPrice,totalPrice from WeighingRecord where datediff(Day,Entrytime,'" + uiDatetimePicker1.Value + "')=0";
Entrytime 是我資料庫中的時間,我想要實作挑選出資料庫中與控制元件中選擇的時間是同一天的資料,但是會報錯:System.Data.SQLite.SQLiteException:“SQL logic error no such column: Day”
這個該怎么解決?
uj5u.com熱心網友回復:
SQL不要這么寫 直接Entrytime between A AND BA 就是日期的值 如:2020-01-01 00:00:00
B 就是日期加1 如2020-01-02 00:00:00
解決了速度上分
uj5u.com熱心網友回復:
另外講一下,聚合這東西性能最差。使用> <大于小于都好。性能好很多。uj5u.com熱心網友回復:
day是什么,沒有這一列sqlite的函式支持和sql server不同
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/60605.html
標籤:C#
