代码:
"select riqi from news where riqi like'%" + this.TextBox1.Text.Trim()+ "%'";
我输入2008查询成功,我输入2008-04查不到,我想输入2008-04或2008-04-25查询,怎么改??
------解决方案--------------------
- SQL code
select riqi from news where convert(nvarchar(20),riqi,112) like '%200804%'
------解决方案--------------------
根据你服务器的日期设置,略有差异!
- SQL code
select convert(nvarchar(20),getdate(),110)-- 05-06-2008select convert(nvarchar(20),getdate(),111)--2008/05/06select convert(nvarchar(20),getdate(),112)--20080506select convert(nvarchar(20),getdate(),101)--05/06/2008select convert(nvarchar(20),getdate(),102)--2008.05.06select convert(nvarchar(20),getdate(),103)--06/05/2008select convert(nvarchar(20),getdate(),104)--06.05.2008