First Date of Month in Oracle

select to_date(to_char(trunc(trunc(to_date(sysdate,'DD-MON-RRRR'), 'MM'), 'MM'),'DD-MON-YYYY')) from dual

What are you trying to achieve exactly? First day of the current month?
If so,
TRUNC(sysdate,'MONTH')Would do it.
::EDIT::
I noticed that you are applying the TO_DATE() function to SYSDATE. SYSDATE is already a date, there is no need to try and convert it.
HTH!
Edited by: Centinul on Jan 1, 2010 1:19 AM

Similar Messages

  • How to calculate first date of month from a given date in IDT BusinessObjects

    Hello Experts,
    I have a date field in IDT Universe which shows date in this format: Dec 13,2014 12.00.00 PM. Now I want to extract first day and last day of month from this date value. For example: here I want to see Dec 01,2014 12:00:00 PM and Dec 31, 2014 12:00:00 PM in First day of month and Last day of month columns. Also, if database date value is Nov 17, 2014 12:00:00 PM then in first day of month column, it should show Nov 01, 2014 12:00:00 PM and in last day of month it should show Nov 30, 2014 12:00:00 PM.
    I got some google help but 'Date' function is not supported by IDT tool in BusinessObjects.
    Please help.
    Thanks in advance.

    Hi
    Try to use the DB Functions to find out the First and last day. Please find out the below screenshot.
    If DB is BW, you can calculate the First and last day @ BW level use same object in BO directly.
    SQL DB:
    http://docs.oracle.com/html/A95915_01/sqfunc.htm#i1006893
    Oracle DB:
    http://msdn.microsoft.com/en-US/library/ms189794(v=sql.90).aspx

  • First date of month

    Hi experts,
    Plz let me know how to get the 1st date of the month using query, after passing a date in the query:
    My below queries are giving me 1st date of year and last date of the month....Kindly hep...
    SELECT TRUNC(TO_DATE('24-JUN-2011'),'YEAR') FROM DUAL
    SELECT LAST_DAY(ADD_MONTHS('24-JUN-2011',12 -
    TO_NUMBER(TO_CHAR(SYSDATE,'mm')))) FROM DUALHelp appreciated,
    Thnx in advance

    Hi,
    977490 wrote:
    THNX,
    And to get the first date of the month.....Didn't Jeneesh how how to get the first date of the month? Given a DATE dt
    TRUNC (dt, 'MONTH')returns midnight of the first day of the month containing dt. That is, the year and month returned are the same as the year and month of dt, but the day, hours minutes and seconds are 01 00:00:00.
    Did you mean "And to get the *last* day of the month"?
    If so:
    LAST_DAY (dt)returns the year, month, hours, minutes and seconds of dt, with the day changed to the last day of the month.

  • Discontinued value, first date in month

    Hello,
    I have one measure Sales Revenue and I need it to show it in two columns in report. In one column have to be Sales Revenue for week and in other Sales Revenue for week-1
    I solved it in webi - i did two queries and one prompt. The one query containes only dimensions week, the second query containes week-1. In prompt I put only one value.
    Queries are ok, but the output in report containes one values, which is discontinued and I don't know, what does it mean?
    The second question is: How can I show the first day of the month?
    Thank you for your answer. Have a nice day,
    Marika

    at the "Data" tab, where you can see all the dimensions and measures
    go down , you will find an option to show alphaptical or by query
    select Disply by query, so you can see the 2 separate queries with 2 separate items.
    good luck
    Amr

  • How to display all dates of month in oracle forms..pl send full code

    hai every one.
    i have multiple rows of block.
    i want to display all dates in that block.

    Hello,
    +1. Complete Forms Solution described in the Dynamic poplist in a multi-record item. thread.+
    This solution is based on dynamic list population with appropriate predefined record group (the number of such predefined record groups could be rather big --> 1 Continents*Countries.+
    Record Groups can be totally dynamic, so you don't need to have them pre-existing at runtime.
    Francois

  • First Date of the Given date and month

    Hi Evryone,
    I want to extract first day of the given date.
    For Ex: i aam giving date "30-jan-2013" but i want to show "01-jan-2013".
    In Oracle, Trunc function behaving mentioned above. So i need appropriote function in HANA to get the FIRSTDATE....
    I observed HANA Given last_date function but what about First_Date function? can i use it?
    Regards,
    Chandrakanth

    Hi Chandrakanth,
    Did you have a look on this blog:
    SAP HANA: Get the First Date and the Last Date of Month from a Given Date | WuaWua
    There is LAST_DAY in HANA but not FIRST_DAY.
    Since last day of the month may vary but first day of the month will always be '01'. Hence they may not have added that function.
    So either you can follow that approach in the blog or you can simply replace the day '01'.
    Regards,
    Krishna Tangudu

  • Need help with select that month range with flexible first date

    Hello everyone,
    I am trying to create a selection of month range (will be in a WITH clause) for a report to display monthly data. But the first month start date can be any date. (Not necessarily the first date of the month)
    Examples:
    Report input parameters:
    Start Date: 08/10/12
    End Month: Dec 2012
    I was trying to build a with select that will list
    Month_Start, Month_End
    08/10/12, 31/10/12
    01/11/12, 30/11/12
    01/12/12, 31/12/12
    OR
    Month_Start, Next_Month
    08/10/12, 01/11/12
    01/11/12, 01/12/12
    01/12/12, 01/01/13
    End month is optional, so if no value the select will list only
    08/10/12, 01/11/12
    Oracle Database Details is
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    My code so far is
    VARIABLE  P50_START_DATE  VARCHAR2 (10)
    VARIABLE  P50_END_MONTH    VARCHAR2 (10)
    EXEC  :P50_START_DATE  := '10/10/2012';
    EXEC  :P50_END_MONTH   := '31/12/2012';
      SELECT  to_char(:P50_START_DATE) AS start_date
            ,  ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), 1) AS next_month
      FROM dual
      union
       SELECT to_char(ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM-1)) AS start_date
       ,      ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM) AS next_month
       --, rownum
       from all_objects
       where
       rownum <= months_between(to_date(NVL(:P50_END_MONTH, :P50_START_DATE),'DD/MM/YYYY'), add_months(to_date(:P50_START_DATE,'DD/MM/YYYY'), -1))
       and rownum > 1If I put comment – on line and rownum > 1, as
    -- and rownum > 1The result I get is
    START_DATE                     NEXT_MONTH               
    01/10/12                       01/10/12                 
    01/11/12                       01/11/12                 
    01/12/12                       01/01/13                 
    10/10/2012                     01/11/12    But when I try to remove the duplicate period (of the first month) out by restrict rownum, it do not return any rows for the second select at all. The result I get is:
    START_DATE                     NEXT_MONTH               
    10/10/2012                     01/11/12    Can anyone advise what wrong with the select statement ?
    Thanks a lot in advance,
    Ann

    Hi,
    Here's one way:
    WITH   params      AS
         SELECT     TO_DATE (:p50_start_date, 'DD/MM/YYYY')     AS start_date
         ,     TO_DATE (:p50_end_month,  'DD/MM/YYYY')     AS end_date
         FROM     dual
    SELECT     GREATEST ( start_date
               , ADD_MONTHS ( TRUNC (start_date, 'MONTH')
                            , LEVEL - 1
              )               AS month_start
    ,     LEAST     ( end_date
              , ADD_MONTHS ( TRUNC (start_date, 'MONTH')
                          , LEVEL
                        ) - 1
              )               AS month_end
    FROM    params
    CONNECT BY     LEVEL     <= 1 + MONTHS_BETWEEN ( end_date
                                      , TRUNC (start_date, 'MONTH')
    ;:p50_end_month doesn't have to be the last day of the month; any day will work.
    If you want to generate a Counter Table containing the integers 1 througn x in SQL, you could say
    SELECT  ROWNUM  AS n
    FROM    all_objects
    WHERE   ROWNUM  <= x
    ;but, starting in Oracle 9.1, it's much faster to say
    SELECT  LEVEL   AS n
    FROM    dual    -- or any table containing exactly 1 row
    CONNECT BY  LEVEL <= x
    ;Also, x can be greater than the number of rows in all_objects.

  • Expression - First date and last date of current month, current year

    Hi
    I need to have 2 ssrs expression as I can use  as default parameters in my report where I can -  out from my Time dimension, get the
    first date of the current, current year - and one where I get last date, current month, current year.
    My data source is a SSAS cube and my timedimension is structured like this:
    [Time].[Days].&[2009-01-16T00:00:00]
    Any suggestions how to solve this ?

    Hi ,
    You can use below in Default Values in ssrs ;
    for first Day of current month and year
    ="[Time].[Days].&[" +Format(dateadd("m",0,dateserial(year(Today),month(Today),1)), "yyyy-MM-dd")+"T00:00:00]"
    output will be ;
    [Time].[Days].&[2014-09-01T00:00:00]
    For last day of current month and year
    ="[Time].[Days].&[" +Format(DateSerial(Year(Now()), Month(Now()), "1").AddMonths(1).AddDays(-1), "yyyy-MM-dd")+"T00:00:00]"
    output will be ;
    [Time].[Days].&[2014-09-30T00:00:00]
    Please correct me if I misunderstood your requirement.
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem.

  • To get first date and end date after entering any month and year

    Hi,
    I need to to get first date and end date of a month and year in yyyyMMdd format. I am reading month and year from a properties file. But I don't know how to get the first date and End date in given format. The properties file gives me just text. But I don't know how to get the date format using this. I need this urgently. Can anyone help me to get code for this?
    I am reading the fields as,
    Properties props = new Properties();
    props.load(new FileInputStream("AnyMonthVolume.properties"));
    String date_month = props.getProperty("date_month");
    String date_year = props.getProperty("date_year");
    Thanks.

    I know this has been posted a while ago but incase someone looking for it, here is the code to get the end of current month date.
    Calendar cal = Calendar.getInstance();
         cal.setTime(new java.util.Date());
         cal.set(Calendar.DATE, 1); //set the date to start of month
         cal.add(Calendar.MONTH,1);
         cal.add(Calendar.DATE,-1);
    System.out.println(cal.getTime());

  • How to get month last date and first date without FM's

    Hi Guru's,
       How can we get  month's first date and last date based on the date given in selection screen without FM's?Is it possible ?
    Like if i give 05-Oct-2008 in the selection screen, i should get the output as 01-Oct-2008 to 31-Oct-2008.Without FM's???
    Regards
    Rakesh.

    Hi Rakesh,
    You can implement this logic as follows:
    You can have two internal tables, one containing the days as numbered 31, 28, 31, and so on with the month number. This holds good if the year is a common year. Another internal table contains days as numbered 31, 29, 31 and so on with the month number. This year would be a leap year.
    An year can be calculated depending on the conditions:
    Say date is given as 20081008
    Concatenate 20081001 + 0(4) into l_date.
    Divide l_date by 4 and remainder should be equal to 0.
    Divide l_date by 400 and remainder should also be equal to 0.
    Then the dominical year will be a leap year.
    Now, if l_date divided by 100 and the remainder is 0 then the year is a common year.
    So depending on this populate the first date and last date from the respective internal table
    Regards,
    Sumalatha N.

  • Previous month first data and previous month last date

    can any body have query to get previous month first date and previous month last date.
    Ex: First day of the previous week:
    TIMESTAMPADD(SQL_TSI_DAY,-6, (TIMESTAMPADD(SQL_TSI_DAY, DAYOFWEEK(CURRENT_DATE) *-1,CURRENT_DATE)))
    Last day of the previous week:
    TIMESTAMPADD(SQL_TSI_DAY, DAYOFWEEK(CURRENT_DATE) *-1,CURRENT_DATE)
    can anybody have it for first day of the previous month,last day of the previous month?
    Edited by: user12255470 on Apr 7, 2010 3:30 AM

    Hi,
    1st day of previous month :
    TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)) * -1) + 1, TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE))
    last day of previous month :
    TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)) * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)))
    Please mark Q answered and award points for correct answers !
    Thanks
    Alastair

  • Default value of date as first day of month

    Ho can I make my default value of date parameter as first day of month? {$SYSDATE()$} gives only current date and we can make it like {$SYSDATE()-7$} if we want to minus 7 days but how can we set the default value to first day of month?

    I got the answer...It is {$FIRST_DAY_OF_MONTH()$} instead of {$SYSDATE()$}

  • Select records by date after first of next month

    Hi
    I have an asp app accessing a SQL Server db and am getting
    myself into a tangle over dates. I have a date field ValidFromDt
    (smalldatetime) and another date field ValidUntilDt which
    respectively define when a record is valid from and until. I want
    to select all records valid on the first of next month - i.e. were
    now in July so I want any whose 'valid from' date is now or any day
    up to 1 Aug but excluding those which expire before 1 Aug and also
    those whose valid from date is 2 Aug or later. Whatever month we're
    in, it is the first of next month I want to select up until.
    Any suggestions much appreciated.
    Thanks
    TP

    Try...
    SELECT yourTable.* FROM yourTable WHERE
    CSng(Month([ValidFromDt]))>CSng(Month(Date()))

  • First date of the month

    How to calculate the first date of the month on basis of YYYYMM month format ?
    Sanjay

    Hi User,
    If you try using
    SELECT TO_DATE ('201211' || '01', 'ÝYYYMMDD')
      FROM DUAL;We get error as
    >ORA-01821: date format not recognized
    Just Try doing this,
    Convert to CHAR format and Use the Date Function to convert to Date.
    SELECT TO_DATE (TO_CHAR (:STRING || '01'), 'YYYYMMDD')
      FROM DUAL;Input :
    String - 201112
    Output :
    Date
    12/1/2011
    Thanks,
    Shankar

  • Get first and last date of month

    Hi,
      Is there any function module to get first and last date of month for a entered date.
    Please let me know.
    Regards,
    SP

    Hi,
    Use the below FM to find the Last day of month and them u can easily calculate the first day.
    DATA : v_startdate TYPE sy-datum.
    DATA : v_enddate TYPE sy-datum.
    DATA : v_temp TYPE dats.
    v_temp = sy-datum.
    CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
        EXPORTING
          day_in            = v_temp
        IMPORTING
          last_day_of_month = v_enddate
    CONCATENATE  v_enddate+0(6)  '01'  INTO  v_startdate.
    Hope it helps.
    Regards,
    Arnab.

Maybe you are looking for

  • Outputing to 2nd Monitor

    Our facility is streaming using Adobe Media Live Encoder.  We are building a new facility and I want to send the output of the stream to NTSC output of my video card so we can monitor the stream from the office area.   My goal is to have the output o

  • HT2353 Macbook Pro running slow and freezing

    So it just started yesterday running slow and freezing. I'm starting to get very frustrated. I research to see what could be the problem. I saw people suggesting that it could be the storage. My storage is 464.75 free out of 499.25. I just brought th

  • Can we burst a report output into Reports manager repository?

    We have a requirement to burst a FSG and Account Analysis report into a Reports Manager repository such that multiple files can be created (specially for Account Analysis Report). Can this be done? Any direction as to how, and sample code would be he

  • DHCP support for weblogic app servers

    Hey there, Iam new to this product. I wanted to know if any of the weblogic app servers support DHCP. What I mean is if the IP address changes then would it automatically pick it up? -Samit

  • NIK plug-ins not working with LR4

    Does anyone have any updated info on when Adobe are going to do something?