select CONVERT(varchar(10), getDate(),120) --不要时间2002-1-1
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108)  ---06:05:05

解决方案 »

  1.   

    你用这个:sql = "select record.*,student.name,student.class from record,student where datediff(day,intime,'" & CStr(date1) & "')=0 and student.stucard=record.stucard"如:
    select datediff(day,'2001-1-1','2002-1-1') 天
    select datediff(month'2001-1-1','2002-1-1') 月
    select datediff(year,'2001-1-1','2002-1-1') 年
      

  2.   

    Select Convert(VarChar(10),GetDate(),20) -- 2003-08-15
      

  3.   

    convert函数不对吧,提示convert未定义,而且我在在线图书帮助里也找不到这个函数阿
      

  4.   

    declare @tt datetime
    set @tt='2003-1-1 12:22:33'select convert(varchar(10),@tt,111)但是建议不要使用,因为111是我仇恨的小日本格式
      

  5.   

    呵呵,那是你装的不全了,上面的方法是肯定没问题,先用CONVERT转换成相应的格式,再通过前边字符串的长度来截取想要的数据
      

  6.   

    那请问convert函数怎么个用法?怎么看得迷糊
    convert(varchar(10),@tt,111)
    这个111,有的又是102,有什么用?有何区别?
      

  7.   

    to:chao778899(220330) 
    在线图书帮助还能只装一部分么?
      

  8.   

    进一步说,如果是在access下怎么办呢?不能用convert