C資料庫求SQL語句查詢指定時間

2021-03-08 11:54:40 字數 1865 閱讀 7525

1樓:三葉草

f_date裡面既然已是時間日期數

據型別,那麼就無需在轉成什麼如2009

722這種格式了。我們在外面只要把所要查詢的日期範圍,應該是2個日期,把它們的格式弄好就可以了

string datemin=datetime.parse("2023年5月1日 00:00");

string datemax=datetime.parse("22023年7月1日 12:12");

然後寫sql語句如下:

string strsql="select * from t_chart where f_date>='"+datemin+"' and f_date<='"+datemax+"'";

2樓:何以

string型的 後面能用daretime.parse?不是一個型別會報錯吧!

3樓:郭某人來此

1、兩個日期間

select * from t_chart where convert(varchar(30),f_date ,120)>='2009-7-1' and convert(varchar(30),f_date ,120)<='2009-7-31'

select * from t_chart where convert(varchar(30),f_date ,120) between '2009-7-1' and '2009-7-31'

2、某個月的資料

select * from t_chart where convert(varchar(30),f_date ,120)like'%2009-05%'

3、某一年的資料

select * from t_chart where convert(varchar(30),f_date ,120)like'%2009%'

4樓:

select f_date from t_chart where f_date between 開始日期 and 結束日期

開始日期例如:2010-1-1

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

5樓:匿名使用者

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'

6樓:匿名使用者

datetime starttime = datetimepicker1.value;

datetime endtime = datetimepicker2.value;

string sql = string.format("select * from sales where 售出時間 >=' and 售出時間

<='", starttime, endtime);

7樓:

string sql = string.format("select * from sales where 售出時間 between '' and ''","2015-1-1","2015-4-3");

8樓:匿名使用者

我就想問問 用ef怎麼寫

sql資料庫題求大神幫忙,sql資料庫題求大神幫忙

if object id n member is not null drop table membercreate table member mid char 10 not null primary key,mname char 50 not null goexec sp addextendedpr...

sql如何查詢空值的欄位,sql資料庫查詢中,空值查詢條件怎麼寫?

sql查詢空值的欄位寫法 select a.欄位 from student a where a.欄位 like student為表名 查詢類似空值的寫法 1 查詢名稱有退格鍵 select from t bd item info where charindex char 8 item name 0 ...

跪求oracle資料庫sql語句,高手進來幫忙

不知道你不是初學者,那若是初學者,就聽一下吧,自動增加,可以建一個序列,即sequence,具體你可以看看這個 等你學會了序列,你就知道怎麼自動增加了!一句話完成不了,用序列,有2 種處理方法 你真要多看書阿。下面這個就是建立序列的語句阿,create sequence seq increment ...