Print All dates of one month on Oracle SQL
How do I print all dates of a particular month by Oracle SQL
Topic Introduction: In this tutorial, we will discuss how to find out or retrieve all data of a month using SQL Query. It mostly uses for attendance reports of a specific month. I have given a sample query and its output results below.
SELECT TRUNC (TO_DATE(TRUNC(SYSDATE,'MON'),'DD-MON-RR') + ROWNUM)-1 DATE_LISTFROM DUAL CONNECT BY ROWNUM < (TO_DATE(LAST_DAY(SYSDATE),'DD-MON-RR')-TO_DATE(TRUNC(SYSDATE,'MON'),'DD-MON-RR'))+2;
In the above, I have used sysdate which indicates the system's present month. if you want want you can use Parameter instant sysdate which will specify the month by using the date parameter. for example, I have given a query that also returns all dates of a month.
Find out the date list of a month using a date parameter
SELECT TRUNC (TO_DATE(TRUNC(:PDATE,'MON'),'DD-MON-RR') + ROWNUM)-1 DATE_LISTFROM DUAL CONNECT BY ROWNUM < (TO_DATE(LAST_DAY(:PDATE),'DD-MON-RR')-TO_DATE(TRUNC(:PDATE,'MON'),'DD-MON-RR'))+2;
No comments