to_date 函数与 sysdate

2021-12-30 00:00:00 oracle11g oracle oracle10g sysdate
select TO_CHAR(to_date(sysdate, 'DD-MON-YYYY'), 'DAY') FROM DUAL; 

当我运行这个查询时,输出是:SUNDAY.但我们知道今天是星期二(1-1-2013).还有

When I run this query the output was : SUNDAY. But we know today is Tuesday(1-1-2013). And

然后将查询更改为

select TO_CHAR(to_date('01-JAN-2013', 'DD-MON-YYYY'), 'DAY') FROM DUAL;

答案是:星期二.

然后将查询更改为

select TO_CHAR(to_date(sysdate+1, 'DD-MON-YYYY'), 'DAY') FROM DUAL;

答案是:星期一.

当我使用 sysdate 时,为什么它显示 SUNDAY 作为输出?

When I using the sysdate why it is show SUNDAY as output?

我是 oracle 数据库的新手.请帮帮我.

I am new in oracle db. Please help me.

推荐答案

使用这个:

 select TO_CHAR(sysdate, 'DAY') FROM DUAL;

你正在使用这个:

 to_date(sysdate, 'DD-MON-YYYY') 

这给你 date=1/1/0013 即星期日

which is giving you date=1/1/0013 which is sunday

相关文章