How to get the current year in ORACLE?

8

I need to get the annual year in ORACLE, but I just know how to get the current date, like this:

SELECT SYSDATE FROM DUAL

Can you manipulate this to get the Year?

    
asked by anonymous 27.02.2014 / 19:27

2 answers

6

The function EXTRACT allows you to extract the different parts of a field or variable that contains date, time, or a range.

To get the current date, use the EXTRACT(YEAR FROM sysdate) excerpt, as in the query example:

select EXTRACT(YEAR FROM sysdate) from dual;
    
27.02.2014 / 19:29
3

Using to_char:

select to_char(sysdate, 'YYYY') from dual;
    
27.02.2014 / 19:30