DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: 1st Day of the Month - SQL*Plus

  1. #1
    Join Date
    Jul 2001
    Posts
    334

    1st Day of the Month - SQL*Plus

    Hi All,

    How I can get the 1st day of the month, I mean let's say today date is 20-JUL-05 and I need 01-JUL-05.

    Thanks in advance

  2. #2
    Join Date
    Jul 2001
    Posts
    334
    No problem; I got it. below is the solution

    SELECT '01-'||to_char(sysdate,'MON-YY') FROM DUAL

  3. #3
    Join Date
    Jul 2005
    Posts
    4
    Quote Originally Posted by aph
    No problem; I got it. below is the solution

    SELECT '01-'||to_char(sysdate,'MON-YY') FROM DUAL
    Here is a more elegant yet simple solution that returns a date instead of a string:
    Code:
    select trunc(sysdate,'mon') first_of_month 
    from dual
    If you still want the date as a formatted string:
    Code:
    select to_char(trunc(sysdate,'mon'),'DD-MON-YY') first_of_month 
    from dual
    Eddie Awad
    awads.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width