CONVERT(nvarchar(10),
getdate(),126)

解决方案 »

  1.   

    错了是这样的
    table1:
    inserttime       info   data  other
    2003-4-5 12:1:2   xx     23.3  ...
    2003-4-5 13:10:3   xx    22.4   ...
    我现在想取2003-4-5的数据怎么取??
      

  2.   

    select * from table1 where convert(nvarchar(10),inserttime,120)='2002-04-05'
      

  3.   

    select * from table where inserttime like '%2002-04-05%'
      

  4.   

    select * from table1 where datepart(yy,inserttime)=2003 and datepart(mm,inserttime)=4 and datepart(dd,inserttime)=5 
    虽然麻烦些,但绝对无问题。
      

  5.   

    SELECT * FROM table1 WHERE inserttime>=2003-4-5 00:00:00 000 AND inserttime<=2003-4-5 23:59:59 999
    这个绝对可行,我们现在就是这样处理的。
      

  6.   

    select * from table1 where year(inserttime)=2003 and month(inserttime)=4 
    and day(inserttime)=5