我的sql是:
sql1="select id,title,what,how,swhen,swhere,demand,Number,Price,about from [plan] where convert(varchar(10),stime,120) like '%2003-8%' order by stime desc";
但是这句话查不出来,我传的是yy-mm,可以吗?
...全文
382打赏收藏
怎样查询时间?
我的sql是: sql1="select id,title,what,how,swhen,swhere,demand,Number,Price,about from [plan] where convert(varchar(10),stime,120) like '%2003-8%' order by stime desc"; 但是这句话查不出来,我传的是yy-mm,可以吗?
你传的已经不是时间格式的值了
你试试看这样做
where 时间字列名 like DateTime.Parse(你的时间字符串);
DateTime.Parse转换的是yyyy-mm-dd 00:00:00的格式
如果你想要yyyy-mm-dd的格式话,可以这样
DateTime.Parse(你的时间字符串).ToShortDateString();