w3resource

Oracle: First and last day of the current year

Oracle Datetime: Exercise-5 with Solution

Write a Oracle SQL statement to get the first and last day of the current year.

Sample Solution:

Oracle Code:

SELECT TRUNC (SYSDATE, 'YEAR') "First Day of the year" FROM DUAL;
SELECT ADD_MONTHS (TRUNC (SYSDATE, 'YEAR'), 12) - 1 "Last Day of the Year" FROM DUAL;

Output:

  	First Day of the year
1	1/1/2021 12:00:00 AM

  	Last Day of the Year
1	12/31/2021 12:00:00 AM

Improve this sample solution and post your code through Disqus.

Previous: Write a Oracle SQL statement to determine how many days are left in the current month.
Next: Write a Oracle SQL statement to get the number of days in current month.

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/oracle-exercises/datetime/oracle-datetime-exercise-5.php