Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

to_date function with sysdate

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

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

then changed the query as

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

answer was :TUESDAY.

then Changed query as

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

answer is :MONDAY.

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

I am new in oracle db. Please help me.

like image 743
ıllıllı lק ıllıllı Avatar asked Dec 27 '22 12:12

ıllıllı lק ıllıllı


1 Answers

use this:

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

you are using this :

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

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

like image 136
Nipun Jain Avatar answered Jan 29 '23 04:01

Nipun Jain