Menu Close

SQL Date Functions

SQL

The SQL code to get the first day of the current year using Oracle SQL:

SELECT TRUNC(SYSDATE,'YEAR')
FROM DUAL;

The SQL code to get the first day of the current month using Oracle SQL:

SELECT TRUNC(SYSDATE, 'MON') 
FROM DUAL;

Current year (extract from SYSDATE) using Oracle SQL:

SELECT EXTRACT(YEAR FROM SYSDATE) AS YearNumber
FROM DUAL;

Get the first Monday in the following Month using Oracle SQL:

SELECT NEXT_DAY(LAST_DAY(SYSDATE + 1), 'MONDAY')
FROM DUAL;

Related Posts

Posted in Bildung, Datenbank