表1:
    date   hour   min
20060105     0     1
20060105     5     9
20060105    10    23希望能转换为一个datatime字段:
  f_datetime
2006-01-05 00:01
2006-01-05 05:09
2006-01-05 10:23请帮忙解决,谢谢!

解决方案 »

  1.   

    对,应该为:
      f_datetime
    2006-01-05 00:01:00
    2006-01-05 05:09:00
    2006-01-05 10:23:00有办法转换吗?
      

  2.   

    create table test(date char(8),hour char(2),min char(2))
    insert test(date,hour,min)
    select '20060105','0','1' union all
    select '20060205','5','9' union all
    select '20050123','10','23'select * from test
    select cast(left(date,4) + '-' + substring(date,5,2) + '-' + right(date,2) 
    + ' ' + hour + ':' + min + ':' + '00' as datetime)from testdrop table test