我传入一个时间
select to_date(to_char(sysdate,'yyyy-mm-dd '),'yyyy-mm-ddd') from dual;
这样的操作是错误的
我就是想得到传入的时间
最后转化为 2010-3-31 这样的格式 小时分钟 全部默认为0
应该怎么写 像我那样写法好像是错的.
select to_date(to_char(sysdate,'yyyy-mm-dd '),'yyyy-mm-ddd') from dual;
这样的操作是错误的
我就是想得到传入的时间
最后转化为 2010-3-31 这样的格式 小时分钟 全部默认为0
应该怎么写 像我那样写法好像是错的.
is
begin
open o_cur for 'select empno, ename, job, mgr, hiredate, sal, comm, deptno from emp where hiredate>=to_date(:i_fromdate,''YYYY-MM-DD'') and hiredate<to_date(:i_todate,''YYYY-MM-DD'')+1'
using i_fromdate, i_todate;
end;
/var o_cur refcursor;
exec emp_proc('1981-01-01','1981-12-31',:o_cur);
print o_cur;
-- 然后在SQL语句中用to_date()函数转换一下
-- 看我上面的例子!
-- 示例如下:
create or replace procedure emp_proc(i_fromdate date, i_todate date, o_cur out sys_refcursor)
is
begin
open o_cur for 'select empno, ename, job, mgr, hiredate, sal, comm, deptno from emp where hiredate>=:i_fromdate and hiredate<:i_todate+1'
using i_fromdate, i_todate;
end;
/var o_cur refcursor;
exec emp_proc(to_date('1981-01-01','yyyy-mm-dd'),to_date('1981-12-31','yyyy-mm-dd'),:o_cur);
print o_cur;
select to_date(to_char(sysdate,'yyyy-mm-dd '),'yyyy-mm-ddd') from dual;-- 修改为:
select to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd') from dual;-- 闲的蛋疼,就去妓院,别来这里瞎扯!
谢谢 大家
-- 今年的第一天:
select trunc(sysdate,'yyyy') from dual;-- 本月的第一天:
select trunc(sysdate,'mm') from dual;-- 本周的第一天:
select trunc(sysdate,'day') from dual;-- 今天的0点:
select trunc(sysdate,'dd') from dual;
select add_months(trunc(sysdate,'mm'),-1) from dual;-- 同理(去年的第一天)
select add_months(trunc(sysdate,'yyyy'),-12) from dual;