Oracle Date/Time Operations



Checking whether current year is a 'Leap Year'

select 
	to_number(to_char(sysdate,'YYYY')) Year,
	case
		when mod(to_number(to_char(sysdate,'YYYY')),400) = 0 then 'Leap Year'
		when mod(to_number(to_char(sysdate,'YYYY')),100) = 0 then 'Not Leap Year'
		when mod(to_number(to_char(sysdate,'YYYY')),4) = 0 then 'Leap Year'
		else 'Not Leap Year'
	end as "Leap Year?"
from dual;

Checking whether current date is weekday or weekend

select 
	to_char(sysdate,'Day') Day_Of_Week,
	case
		when to_char(sysdate,'D') in (1,7) then 'Weekend'
		else 'Weekday'
	end Day_Type
from dual;

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.