这是什么地方的函数,SQL里面用cast(field as datetime)

解决方案 »

  1.   

    日期类型和字符串类型----
    函數convert  
      

  2.   

    先用convert转换为字符再用字符串函数去截断相关字符
      

  3.   

    select   *   from   OTO_Log   where   ActiveTime   Like   '%Year-Month-Day%'   上面这个根本就不对,这是比较字符串,日期不能这样比较字符串转日期类型用cast
    select * from OTO_Log where ActiveTime > cast('year-moth-day' as datetime)  
      

  4.   

    select datename(week,ActiveTime) myweek , count(*) 
    from OTO_Log where convert(varchar(7),ActiveTime,120) = '2008-01' 
    group by datename(week,ActiveTime)