现表中一字段 endtime 格式如:2004-12-3 15:00:00
求所有endtime=now.date(如:2004-12-3)的记录,这个应怎么写SQL语句呀.

解决方案 »

  1.   

    我写的,不过有问题   Dim myendtime As DateTime
            myendtime = Now.Date
            Dim myconn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("conn"))
            Dim mycmd As String = "select pro_bh,pro_name,end_time from pro_bmyq where end_time like " & myendtime & " "
      

  2.   

    select pro_bh,pro_name,end_time from pro_bmyq where datediff(d,getdate(),end_time) =0
      

  3.   

    条件语句设成这样,其中'2004-12-3 15:00:00'可以替换成你传入的参数变量:
    where datediff(dd,'2004-12-3 15:00:00',endtime)=0
      

  4.   

    你看看这个SQL语句是不是你要的
       "SELECT convert(char(10),JoinDate,120) as JoinDate  FROM Articles
      

  5.   

    convert(char(10),endtime ,121)=convert(char(10),getdate(),121)
      

  6.   

    select * from table where 
    convert(char(10),endtime ,121)=convert(char(10),getdate(),121)
      

  7.   

    SELECT * 
      FROM Articles 
     WHERE CONVERT(char(10),endtime ,121) = CONVERT(char(10),getdate(),121)
      

  8.   

    谢谢各位了, cpp2017(幕白兄) 的我用了,可以