1樓:匿名使用者
select * from 表a
where substring(convert(varchar,欄位名,120),12,8) between '08:00:00' and '10:00:00'
試試這樣,看看結果對不
2樓:景琪家園
首先 把所有的 轉換成 日期型別,之後用日期 所對應的函式,between and 即可
3樓:匿名使用者
sql2005
資料表資料
b_1 b_2(datetime)1 2013-05-23 10:44:46.
7802 2013-05-23 10:44:48.
0903 2013-05-23 10:44:49.
8574 2013-05-23 10:44:50.
700select b_1,b_2 from bb where b_2>'2013-05-23 10:40:45' and b_2<'2013-05-23 10:
44:50'
查詢結果:
b_1 b_2
1 2013-05-23 10:44:46.
7802 2013-05-23 10:44:48.
0903 2013-05-23 10:44:49.857
4樓:
select * from a where datedepart(hh,datetime)>=8 and datedepart(hh,datetime)<10
sql語句查詢特定時間段的資料怎麼寫
5樓:海天盛筵
sql伺服器:
select*fromtablewhere'2008-7-1'和'2008-12-31'
訪問:62616964757a686964616fe78988e69d8331333433626537
從表中選擇發生日期》#2008-7-1#和發生日期<#2008-12-31#
就是這樣:注意,sqlserver中的日期和訪問有一點不同。
擴充套件資料:
sql查詢日期語句
select*fromshoporderwheredatediff(week,ordtime,getdate()-1)=0//查詢第一年的日期
select*fromshoporder,其中datediff(day,ordtime,getdate()-1)=0//查詢當天的所有資料
select * from a where datediff(d,datetime,getdate()) <=30 //前30天
select * from a where datediff(m, shijian, getdate()) <=1 //上個月
搜尋當天記錄的其他方法:
select*
fromj_gradeshop
其中(gaddtimebetweenconvert(datetime,left(getdate(),10)+'00:00:00.000'))
並轉換(datetime,left(getdate(),10)+'00:00:00.00.000')+1)
由gaddtime指定的訂單
6樓:匿名使用者
select * from 表 where 日期du字zhi段dao
內>='開始日期' 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'
7樓:匿名使用者
select * from table_name where convert(char(14),你的
bai時du間字zhi段dao名版稱權,20) between '20100701192000' and '20100731212000'
8樓:
是抄sql server資料庫吧襲
。表table1,欄位d,如下
select * from table1
where year(d)=2010 and month(d)=7 and day(d) between 1 and 31
and (datepart(hour,d)>=22 or datepart(hour,d)<6)
怎樣查詢SQL資料庫中某表中的某個列的數值的所有行資料
select from 表名 where 列名 數值 怎樣查詢sql資料庫中某一個表中的某個列的一個數值的所有行資料 怎樣查詢sql資料庫中某一個表中的某個列的一個數值的所有行資料?怎樣查詢sql資料庫中某一個表中的某個列的一個數值的所有行資料 以該列等於某一值進行篩選就可以了。例如 select ...
如何刪除資料庫中的一行,如何刪除資料庫中某一列的值
刪除資料庫中的一行分為以下幾個步驟 1 通過資料庫訪問客戶端 例如訪問oracle,使用plsql 使用有刪除許可權的使用者登入資料庫 2 執行刪除指令碼 delete from tablename where id 11 這裡假設刪除的表名為tablename,標識要刪除行的欄位為id,值為11 ...
oracle資料庫sql語句表中存id 時間用select語句數出每個id分別在幾個時間段裡出現次數
可以使用case when select id,count case when to char v date,yyyymmddhh24mi between s and e then 1 else 0 end as num1,count case when to char v date,yyyymmd...