9
I need to get the annual year on ORACLE, but I only know how to get the current date, so:
SELECT SYSDATE FROM DUAL
You can manipulate it to get only the Year?
9
I need to get the annual year on ORACLE, but I only know how to get the current date, so:
SELECT SYSDATE FROM DUAL
You can manipulate it to get only the Year?
7
The function EXTRACT
allows extracting different parts of a field or variable containing date, time or range.
To get the current date, use the snippet EXTRACT(YEAR FROM sysdate)
, as in the query for example:
select EXTRACT(YEAR FROM sysdate) from dual;
3
Using to_char:
select to_char(sysdate, 'YYYY') from dual;
Browser other questions tagged sql oracle query date
You are not signed in. Login or sign up in order to post.
In this situation would there be a problem when comparing the result with some number? For example if this query returns "2014", when using the < operator comparing to the 300 number what would be the result?
– Joao Paulo
Using the 4y YYYY returns 2014, for example if comparing with a number converts automatically. To_char(sysdate,'yyyy') < 2015 returns true.
– Motta