關於SQL時間類型的模糊查詢


1.Convert轉成String,在用Like查詢。

select * from table1   where convert(varchar,date,120) like   '2006-04-01%'  

 

2.Between

select * from table1 where time between '2006-4-1 0:00:00' and '2006-4-1 24:59:59'";

SQL語句根據具體時間查詢數據

時間格式為:年/月/日 時:分:秒

例如:2017/2/28 16:23:23

sql語句為:selecte * from A where createtime=to_date('2017/2/28 16:23:23' ,'yyyy/mm/dd hh24:mi:ss');


 

3 datediff()函數

select * from table1   where datediff(day,time,'2006-4-1')=0


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM