小弟在做一个电子考勤,如果是默认数据 0001/1/1 就显示  无,可是如果不是 000/1/1 不知道如何显示 正常的数据?我的 Time 字段是 datetime类型的,SQL语句里 第2个 then 想直接写字段Time,会说不是时间格式,但是又不能写 'to_date(Time , 'yyyy-mm-dd')' 也会说格式不正确求高人帮忙啊
select case when Time = to_date('0001/1/1', 'yyyy-mm-dd') then '无' when checktimeIn != to_date('0001/1/1', 'yyyy-mm-dd') then '' end Time  from Attendance

解决方案 »

  1.   

    楼主何不换一种思考方式呢?select case when to_char(Time,'yyyy/mm/dd') = '0001/01/01' then '无' 
                when to_char(checktimeIn,'yyyy/mm/dd') != '0001/01/01' then '' 
            end as  Time
       from Attendance
      

  2.   

    to_char不能用啊,我在页面要遍历出来 只能转datetime类型呀。。
      

  3.   

    用正规表达式呢??pegexp_like
    具体用法百度下。