Header Ads

Header ADS

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_LIST 
FROM DUAL CONNECT BY ROWNUM < (TO_DATE(LAST_DAY(SYSDATE),'DD-MON-RR')-TO_DATE(TRUNC(SYSDATE,'MON'),'DD-MON-RR'))+2
;


print all dates of a particular month,oracle sql ,oracle interview questions ,oracle sql interview questions for developers ,factors of a particular number ,factor of a particular number ,date functions in oracle ,oracle sql practice exercise




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_LIST 
FROM DUAL CONNECT BY ROWNUM < (TO_DATE(LAST_DAY(:PDATE),'DD-MON-RR')-TO_DATE(TRUNC(:PDATE,'MON'),'DD-MON-RR'))+2
;

No comments

Theme images by Deejpilot. Powered by Blogger.