我现在项目中要用到Mysql和Oracle两个数据库切换,以前版本中Mysql用到了Date()函数,可是我找了关于Oracle的相关资料并没有关于Oracled的Date函数
select 
date(test_time) as testTime,
count(*) as alarmTotal, 
sum(case when alarm_type_id=1 then 1 else 0 end) as exceptionTotal, 
sum(case when alarm_type_id=2 then 1 else 0 end) as thresholdTotal, 
sum(case when alarm_type_id=3 then 1 else 0 end) as interruptTotal 
from alarm_result 
where 1=1 and to_char(test_time,'yyyy-MM-dd') >= '2011-07-31' 
group by testTime 
order by test_time desc 
求大神解决一下吧 ~  我上面贴的是Mysql中关于Date函数写法

解决方案 »

  1.   

    select sysdate from dual; --取当前系统时间
      

  2.   


    --你这句date(test_time) as testTime 可以改为:
    to_char(test_time,'yyyy-mm-dd') as testTime
      

  3.   

    mysql date函数用法
    http://www.w3school.com.cn/sql/func_date.asp--oracle里面想达到这个效果,to_char一下就完了
    to_char(test_time,'yyyy-mm-dd') as testTime,
      

  4.   

    你的test_time是什么格式的?是YYYYMMDD还是什么?
      

  5.   


    数据库中存的是yyyy-MM-dd hh24:mi:ss   在mySql中我可以通过date(test_time)得到yyyy-MM-ss ..Oracle !!!
      

  6.   

    上面给的to_char(test_time,'yyyy-mm-dd') 你在oracle中试了吗?要是有错误,把错误贴出来