Wednesday, May 18, 2011

How to get/show First Date of the Month ?

If you want to show or if you need the month first day, there is no built-in function in Oracle. But you can get it easily by using some other single-row date function. Here bellow an example of this.

SELECT LAST_DAY(ADD_MONTHS(SYSDATE,-1))+1
FROM DUAL;


Run the above sql and you will get the first day of current month. For last day of current month just use the LAST_DAY function like thisLAST_DAY(SYSDATE)

Need more help ? Just Leave you comments...

Cheers

7 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This post shows how to get/show first date of the month. The query for the same is given in this post. The query is simple and easy to understand. This command is easy to learn. Thanks for the post. Keep it up.

    ReplyDelete
  3. I have some useful DB scripts in my collection above a look here -- uses full DB scripts

    ReplyDelete
  4. INSTEAD OF THIS WHAT IS YOUR OPINION ABOUT THE FOLLOWING
    SELECT TRUNC(SYSDATE,'MONTH') FIRST_DAY,
    LAST_DAY(SYSDATE) END_DATE,
    SYSDATE CURRENT_DATE
    FROM DUAL;

    ReplyDelete