1、 dw,weekday -----------表示某個星期的第幾天 ltrim(rtrim(title))----------清除title的左右空格 --查詢同一天的 select * from loginlog where datediff(day,logintime,'2007-12-28')=0 --查詢同一星期的 第一種:select * from loginlog where datepart(week,logintime)=datepart(week,'2007-12-11'); 第二種:select * from loginlog where datediff(week,logintime,'2008-01-16')=0 --查詢同一月的 select * from loginlog where datediff(month,logintime,'2007-12-28')=0 --查詢乙個時間段的 select * from loginlog where datepart(dy,logintime)>datepart(dy,'2007-01-01') and datepart(dy,logintime)
datepart(dy,'2008-01-10') and datepart(dy,logintime)
=12 then substring(notetitle,0,12)+'...' else notetitle end from mynote where createuser='admin' 相關的查詢示例: select * from stumarks --原始成績 pring 'abcde五級顯示成績如下:' select stuno,成績=case when writtenexam<60 thten 'e' when writtenexam between 60 and 69 then 'd' when writtenexam between 70 and 79 then 'c' when writtenexam between 80 and 89 then 'b' else 'a' from stumarks --操作臨時表 select len(sunday1), * from ( select sunday1 from schedule ) temp
SQL日期查詢
查詢本日的記錄 select from tablename where datepart dd,thedate datepart dd,getdate and datepart mm,thedate datepart mm,getdate and datepart yy,thedate datepa...
SQL日期查詢
1.sql查詢今天的資料 比如今日新增 datediff 函式返回兩個日期之間的時間。select from customer where datediff now create time 0 2.查詢昨天的資料 select from customer where datediff now cre...
SQL查詢日期
sql查詢日期 今天的所有資料 select from 表名 where datediff dd,datetime型別字段,getdate 0 昨天的所有資料 select from 表名 where datediff dd,datetime型別字段,getdate 1 7天內的所有資料 selec...