日期:2014-05-18  浏览次数:20827 次

怎样按日期查询DateTime格式的时间?
我是读取当前时间到数据库中:
cm.Parameters[ "@FL_PomptDate "].Value   =   DateTime.Now.ToString();
所以数据库中日期格式为:2007-9-11   15:31:06
而现在我想查询9月11号的数据,请问该怎样写匹配?
我本来是这样写的:
if   (Tbx_date.Text   !=   " ")
                {
                        strsql   =   strsql   +   "and   FL_PomptDate   like   '% "   +   Tbx_date.Text   +   "% ' ";
                }

在线等..谢谢!

------解决方案--------------------
上面手错,写错了个地方

strsql = strsql + " AND DATEDIFF(day,FL_PomptDate,CAST( ' " + Tbx_date.Text + " ' as datetime))=0 ";