Oracle关于时间的处理,日期参数在SQL中的处理

//ok:
select u.investigation_time from t_customer u where TO_CHAR(u.investigation_time,'YYYY-MM-DD')  like '"+参数值+"%'
 
//NO:
select u.investigation_time from t_customer u where u.investigation_time like TO_DATE('"+参数值+"%','YYYY-MM-DD')
 
//ok:
UPDATE  t_customer SET investigation_time=TO_DATE('2008-12-12','YYYY-MM-DD') WHERE customer_id=2

//OK;
temp.append(" AND TO_CHAR(u.investigation_time,'YYYY-MM-DD')  like '"+investigation_time+"%'");
//NO:
temp.append(" AND u.investigation_time LIKE TO_DATE('"+investigation_time+"%','YYYY-MM-DD') ");

 

1.以12小时制显示
     SQL>select to_char(sysdate,'YYYY-MM-DD HH12:MI:SS AM')from dual;

2.以24小时制显示

 SQL>  select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS AM')from dual;

3.得到当前时间的后一天


select to_char(Sysdate+1,'YYYY-MM-DD')from dual;

你可能感兴趣的:(oracle,sql)