怎樣在C中寫一句SQL語句,判斷資料庫中的日期對比系統當前日期是否過期了

2022-06-02 01:05:21 字數 2329 閱讀 4298

1樓:匿名使用者

過期的話應該是表裡的時間小於當前時間

select * from tablename where time < getdate()

看看查詢結果就知道了

2樓:匿名使用者

或者:選擇* from tablename的則datediff(d,getdate(),到期日期)<= 30如果僅統計30天到期:

select * from tablename的 br /> datediff(d,getdate(),到期日)0到30之間

3樓:匿名使用者

直接寫上時刻字串就可以了。

select * from table where time < '2013/04/10 23:13:01『

c# 獲取sql資料庫中的時間並與當前日期計算差值怎麼寫?

4樓:匿名使用者

假定那個欄位是mydate,資料庫為sql server

select datediff(day,mydate,getdate()) from tablename

這個sql的結果取出來就是你要的天數了。

5樓:改天罡

datediff(dd,'20070101',getdate())

c#如何判斷datetimepicker1中的值與sql中的日期相等 100

6樓:塵雨洛煙

你控制元件中的是日期,而資料庫中的是時間時分秒,這兩個沒法比較啊,如果都是日期,可以用where date='控制元件日期',如果帶時間,可以用between來判斷時間段

c#提取資料庫中日期的年份與當前日期的年份的差值

7樓:匿名使用者

呵呵 偷一下懶sqlconnection con = new sqlconnection("連線字串");int id = 設定要查詢的id;string str = "select birthday from table where '" + id + "'";(如用於商用則需要使用引數話查詢)con.open();sqlcommand cmd = new sqlcommand(str,con);sqldatareader dr = cmd.ex……datareader();這裡記不住了0_0;if(dr.

read())con.close();

8樓:匿名使用者

sqlconnection con = new sqlconnection("連線字串");int id = 設定要查詢的id;string str = "select birthday from table where '" + id + "'";(如用於商用則需要使用引數話查詢)con.open();sqlcommand cmd = new sqlcommand(str,con);sqldatareader dr = cmd.ex……datareader();這裡記不住了0_0;if(dr.

read())con.close();手寫版,只供參考

c#:sql server查詢某個時間範圍的語句怎麼寫?

9樓:匿名使用者

select * from 表 where 日期欄位>='開始日期' and 日期欄位<='截止日期'

and convert(char(8),日期欄位,108)>='開始時間內' and convert(char(8),日期欄位,108)<='截止時間'

例如容:

select * from tb1 where ddate>='2010-11-05' and ddate<='2010-11-15'

and convert(char(8),ddate,108)>='22:30:00' and convert(char(8),ddate,108)<='23:00:00'

10樓:匿名使用者

我就想問問 用ef怎麼寫

c#如何判斷datetimepicker1與sql中的日期相等

11樓:匿名使用者

string a = "要進行比較的datetime";

string b = "資料庫中的datetime";datetime.parse(a) == datetime.parse(b))進行轉換後比較

12樓:匿名使用者

取出來值。然後用datetime.parse()把兩個值轉換成datetime格式的 進行比較就行了。

懸賞一句sql語句,懂的進的,懸賞一句sql語句,懂的進的

oracle的寫法 select a.id,a.名稱,a.單位,sum case when b.訂單號 a002 then b.購入數量 else null end 購入數量,sum b.購入數量 累計購入 from a,b where a.id b.id iso sql 92的寫法 select ...

求一句簡單的sql語句。 asp access

select top 1 from select top 168 from infor order by i id tb order by i id desc select top 168 from infor order by i id tb 這行的意思是從原表按順序取出168條資料放在一個虛擬表...

SQL語句在資料庫裡查詢得到資料,在C中卻查不出來,這個怎

除錯看,如果資料庫連線成功,以 看應該有資料出來了,除錯時,在即使視窗中輸出ddd看看結果為不為空 那就是 你c 問題別 你是不是沒有繫結資料比如bind c 語法是不是錯誤,認真檢查一下所寫的c sql語句在資料庫中能查到但用c 中就查不到 10 建議你不要用if reader。read 換成wh...