在sql语句中用year(),month(),day()可以分别得到年月日,可是得到时间的函数就不知道了。

解决方案 »

  1.   

    先转成字符串,格式 yyyy-mm-dd hh:mm:ss 然后随便你怎么处理了convert(char(19),getdate(),121)
      

  2.   

    你可以这样取出你需要的部分year(getdate()),month(getdate()),day(getdate())
      

  3.   

    select convert(char(10),getdate(),20) as mydate,convert(char(10),getdate(),108) as mytime
      

  4.   

    select convert(char(10),getdate(),20) as mydate,convert(char(10),getdate(),108) as mytime,其中mydate格式为yyyy-mm-dd
    mytime格式为hh:nn:ss
      

  5.   

    先转成字符串,格式 yyyy-mm-dd hh:mm:ss 然后随便你怎么处理了convert(char(19),getdate(),121)
      

  6.   

    先感谢各位高手,1.只所以要分成两部分,是一字段是即有日期又有时间想Group by 日期
    2. 我就是时间不知如何取?
    有何好的解决办法?
      

  7.   

    hellohha 说得对我试过了完全正确
      

  8.   

    hellohha(天河水) 确是正确,马上给分,再次感谢各位!
      

  9.   

    yearof (),monthof (),dayof ()可以分别得到年月日,
    组合一下就ok!!!