Date of end of month

Hi all
I have a table "xyz" that captures start_date and end_date in one line.
i.e. start_date = * 15 October 2007 *, end_date = * 25 - dec - 2008 *.

I want to write a query that diplay end of month of each month between start_date and end_date as dates me. .

October 31, 2007
November 30, 2007
31-dec-2007
January 31, 2008
February 29, 2008
31-mar-2008
..
..
..
..
..
..
..
..
31-dec-2008

Thanks in advance

Try this

select
     last_day(add_months(to_date('15-oct-2007','dd-mon-yyyy'),level-1))
from
     dual
connect by level <= ((to_date('01-dec-2008','dd-mon-yyyy') - to_date('01-oct-2007','dd-mon-yyyy'))/30) +1
/
 

Tags: Database

Similar Questions

  • get all the date of end of months between two dates

    Hi all, I'll try to find together the date of end of months between two dates.
    I have the following data in a table

    WITH AS's Data1
    (
    SELECT To_Date('4/30/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual UNION ALL
    SELECT To_Date('5/01/2009','mm/dd/yyyy') dt, "TEST2" lname FROM dual UNION all
    SELECT To_Date('5/02/2009','mm/dd/yyyy') dt, "TEST3" lname FROM dual UNION all
    SELECT To_Date('5/03/2009','mm/dd/yyyy') dt, "TEST4" lname FROM dual UNION all
    SELECT To_Date('5/04/2009','mm/dd/yyyy') dt, "TEST5" lname FROM dual UNION all
    SELECT To_Date('5/05/2009','mm/dd/yyyy') dt, "TEST6" lname FROM dual UNION ALL
    SELECT To_Date('5/31/2009','mm/dd/yyyy') dt, 'TEST7' lname FROM dual UNION all
    SELECT To_Date('6/01/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual

    )

    I would like to write an application that gives you all the end date for months between two dates
    for example, if you give the date 9/1/4 and 5/6/9, the output should be
    DT          LNAME
    -------------------
    4/30/2009   TEST
    IF I give you the dates 01/04/09 AND 01/06/09, THEN output should be
    DT          LNAME
    -------------------
    4/30/2009   TEST
    5/31/2009   TEST7
    as you can see, I want all the end dates of months between two dates by giving the output.

    If I give you 06/05/09 and 05/06/09, and then does so no output because there is no end of month between these two dates.
    Similarly, if I give you 30/04/09 and 30/04/09 then output should be 30/04/09 because it is an end of month date

    anyone can help to write a query. Thank you very much

    Jin
    Not sure if you need subquery, analytical functions for this.
    According to me, which should solve your purpose.

    WITH data1 AS
    (
    SELECT To_Date('4/30/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual UNION ALL
    SELECT To_Date('5/01/2009','mm/dd/yyyy') dt, 'TEST2' lname FROM dual UNION all
    SELECT To_Date('5/02/2009','mm/dd/yyyy') dt, 'TEST3' lname FROM dual UNION all
    SELECT To_Date('5/03/2009','mm/dd/yyyy') dt, 'TEST4' lname FROM dual UNION all
    SELECT To_Date('5/04/2009','mm/dd/yyyy') dt, 'TEST5' lname FROM dual UNION all
    SELECT To_Date('5/05/2009','mm/dd/yyyy') dt, 'TEST6' lname FROM dual UNION ALL
    SELECT To_Date('5/31/2009','mm/dd/yyyy') dt, 'TEST7' lname FROM dual UNION all
    SELECT To_Date('6/01/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual 
    
    )
    select distinct last_day(dt) dt,lname
      from data1
     where dt between &start_date and &end_date
       and last_day(dt) <= &end_date
    
    also, i have another request. how would i do this without using the data i provided. lets say,
     i tell you, give me alll the months end between two dates using dual in the from clause of a query.
    how would you do this in a query or pl/sql? thanks again
    

    Can be like that

    with data1 as(
    select &start_date+level-1 dt from dual
    connect by level <= &end_date-&start_date+1)
    select distinct last_day(dt)
      from data1
     where dt between &start_date and &end_date
       and last_day(dt) <= &end_date
     order by last_day(dt)
    

    See you soon!
    Bobin

    Published by: Buga added query for updated the need

  • date of end of month in SPR

    We must show the date of end of month for a given date in a table.
    The date is March 25, 2008 ", then output should give me 31 March 2008".
    I want to create a new column derived like this in the RPD.
    I think that variables can not help me out here, because we need to have the date of end of month for each value that the date column will hold.
    Please let me know how can achieve us.

    I haven't played a lot with the expression of OBIEE constructor functions but the technique below should work, you can use standard date functions:

    (1) take the month and year of your date column (for example for today, it will be 10/2008) convert it to a string.
    (2) date data type concatenate 01 to the string of the previous step and convert the entire expression. Now you have the first date of the month of your column in a date format.
    ((3) on the date to 2) add 1 month and 1 day to remove and you get the last day of the month for your selected date.

    Should work in OBIEE too.

  • Generating dates from end of month

    Hello

    I have a table with a column as a partition_key, I want to insert all the end dates of month of Jan2009 to Dec2013 in the format below.

    PARTITION_KEY

    20090131

    20090228

    20090331

    .

    20120229.

    .

    20131231

    Please tell us a plsql sql statement (GOLD) for this block.

    SELECT last_day (add_months (DATE ' 2009-01-01',(level-1)))

    OF the double

    connect by level<= months_between(date="" '2013-12-01',date="">

    /

    is good to create lines, how you convert a date in number is easy to find...

    HTH

  • Report of the Group of dates for end of month

    Hi guys

    I need to get 6 months of data grouped by months end dates...

    I need to automate this query so that it looks always to date for the last 6 months

    How do I get there?

    The reason for writing the automated query, it's that this sql script is assigned to the business objects reporting.

    I use the pl/sql

    Here's the DOF

    create the table #Something
    (
    base_date datetime, int connections
    )

    Insert #Something
    Select ' 01 jul 2013', 21 Union all the
    Select ' 02 jul 2013', all 22 union
    Select ' 03 jul 2013', 210 Union all the

    ....

    ...

    Select July 31, 2013,"Union 498
    ' Select ' 01 August 2013 ', 44 Union all the
    ' Select ' 05 August 2013 ', 66 Union all the
    ...

    ....

    Select ' 03 dec 2013", 456 union all
    .

    .

    'Select December 31, 2013,"788

    ..............................................................................

    Desired output

    Connection of base Date

    31 jul 500 (not exact, just randomly)

    August 31 600

    30 sep 356

    31 Oct 676

    30 Nov 544

    31 Dec 456

    ..............................................................................

    Hope this helps

    Hello

    In Oracle, you can do this:

    SELECT LAST_DAY (TRUNC (base_date)) AS last_day_of_month

    SUM (connections) AS total_connections

    OF something

    WHERE base_date > = TRUNC (ADD_MONTHS (SYSDATE,-6), 'MONTH')

    AND base_date<  trunc="" (           ="" sysdate,     ="">

    GROUP OF LAST_DAY (TRUNC (base_date))

    ORDER BY last_day_of_month

    ;

    If you would care to post some CREATE TABLE and INSERT statements so you want the results of work from these data of the sample, then I could test this.

    Using Oracle?  #Something (with a sign # at the beginning) is not valid a table name, and datetime is not a valid data type in Oracle.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

    The query above works if base_date is a DATE or TIMESTAMP.

    Since it is now January 2014, what are "the last 6 months?  The above query assumes that they are the last 6 months, that is, July to December 2013.

    If you mean the current (incomplete) and 5 months before it (i.e. August 2013 to January 2014), then add 1 month to the two deadlines in the WHERE clause:

    WHERE base_date > = TRUNC (ADD_MONTHS (SYSDATE,-5), 'MONTH')

    AND base_date<  trunc="" (add_months="" (sysdate, ="" 1) ="">

  • prompt end of month

    I created an end of month fast with a variable presentation 'months '. This variable should work with a filter at the end of the month, so that when you select a date, for example 30/09/2004, the report should display two info 09/30/2004 and also 30/09/2003 - here is the prompt that I created but I think there's a step I'm missing, please help!

    * Time. "' Fiscal year end date" in timestamp(@{month}{2011-01-31 00:00:00},@{month}{2011-01-31}-12) *.

    Hello

    The statement above should give you results in responses if you have data 2010-01-01 to 2011-01-01.

    In addition, there is a lack of closing brackets in the statement where the error of syntax on dashboard.

    Time. "" Tax period end Date "= timestampadd (sql_tsi_month,-12, date ' @{pmonth} {2011-01-01 00:00:00}" ") or the time. ' ' Fiscal period-end date "= date ' @{pmonth} {2011-01-01 00:00:00}'

    Thank you

  • Reminders do not persist beyond the date of end in lightning. Error or design?

    Reminders do not reappear after having reached the date of "END". Other programs of the calendar, I used keep reminding until the user manually terminates it.

    This is a mistake of lightning or this is normal behavior?

    Currently using:
    TB 31.0b2
    3.3B1
    Vista

    You set the repeat appropriately? In lightning, you will need to define an event to repeat to infinity and ending.

    It seems quite reasonable to me; I guess it's mostly a matter of terminology.

    My calendar is full of repeat events; reminders to change passwords, take out the trash, attend renewals, anniversaries, birthdays etc. So yes, he can do events that recur indefinitely.

    Why you run a beta version?

  • What is the date of end of support for Firefox version 19?

    I wish to confirm the date of end of support for version 19, February 2013?

    Security updates support ends when the next version of Firefox is released, so while Firefox 20 was released 6 weeks ago and 21 Firefox will be available Tuesday, May 14, that means that Firefox 19 is is no longer officially supported.

    I see that you are still running Firefox 17.

    Is there a special reason why you don't have not updated to the current version?

    The version of Firefox Firefox 17 that you are currently running is no longer compatible with security updates

    Please upgrade to the latest version of Firefox 20.0.x.

    • Help > about Firefox
  • What is the date of end SQL server 2008 SP2 support?

    What is the date of end SQL server 2008 SP2 support?

    Have you tried Google? or:

    ASK THE QUESTION IN THE SQL SERVER FORUM:
    http://social.msdn.Microsoft.com/forums/en/category/SQLServer

  • Impossible to update a date of end user responsibility

    Hello

    I want to add the responsibility for management of user sysadmin user.

    When I seek the liability of users under the sysadmin user management, it is present under indirect responsibility.

    End date is already defined as 28-SEP-2015.

    When I try to delete the end date, it does not allow that the column is grayed out and it shows error below:

    FRM: 40200: field is protected against editing.

    Please suggest.

    Kind regards

    Purnima Johari

    Hi problem is solved now. I ran code below:

    Begin
    Wf_local_synch. () PropagateUserRole
    p_user_name-online "SYSADMIN"
    p_role_name => ' UMX | SECURITY_ADMIN',.
    p_start_date-online ' 6 October 2015',.
    p_expiration_date => ");
    -commit;
    End;

    commit;

    This is charged at the date of end user sysadmin for the responsibility for the management of users.

    Kind regards

    Purnima Johari

  • Date of entry into monthly intervals

    Hello

    How could I do a count by month but from a certain date.

    I want to count the number of decreases from. So count on Jan 14, then another month to Feb. 14, March 14 etc...

    Jan - 14Feb - 14Mar - 14Apr - 14-14 mayJun - 14Jul - 14Aug - 14Sep - 14
    5012030etc.

    example:

    SELECT COUNT (*), - the MONTH of

    TABLE

    Group by MONTH

    Hello

    Chloe_19 wrote:

    Hello

    How could I do a count by month but from a certain date.

    I want to count the number of decreases from. So count on Jan 14, then another month to Feb. 14, March 14 etc...

    Jan - 14 Feb - 14 Mar - 14 Apr - 14 -14 may Jun - 14 Jul - 14 Aug - 14 Sep - 14
    50 120 30 etc.

    example:

    SELECT COUNT (*), - the MONTH of

    TABLE

    Group by MONTH

    To map all the dates in a calendar month with a common value, use TRUNC (d, 'MONTH').

    However, grouping which will produce a separate line for each month, not a separate column as you asked.  For the different columns for different months, use SELECT... PIVOT, like this:

    WITH relevant_data AS

    (

    SELECT TRUNC (MONTHS_BETWEEN (hiredate, DATE ' 1981-01-01')) + 1 AS month_num

    FROM scott.emp

    )

    SELECT *.

    OF relevant_data

    PIVOT (COUNT (*)

    FOR month_num IN (1 AS jan_1981

    2 UNDER feb_1981

    --  ...

    12 AS dec_1981

    )

    )

    ;

    Fill in the other months should be easy.

    Output:

    JAN_1981 FEB_1981 DEC_1981

    ---------- ---------- ----------

    0          2          2

    For more info on swivel (including other ways besides SELECT... See the FAQ of the PIVOT forum): Re: 4. How can I convert rows to columns?

  • If anyone has the data to be transferred monthly?

    If anyone has the data to be transferred monthly?

    Cloud license allows 2 activations http://www.adobe.com/legal/licenses-terms.html

    -Install on a 2nd computer http://forums.adobe.com/thread/1452292?tstart=0

    -https://helpx.adobe.com/creative-cloud/help/sign-in-out-activate-apps.html

    -Windows or Mac has no importance... 2 on the same operating system or 1 on each

    -Two activations on one account CAN NOT be used at the same time (to be noted in the link above of the license)

    Remove the license on a computer http://forums.adobe.com/thread/1442423?tstart=0 clouds can help

    -read http://helpx.adobe.com/x-productkb/policy-pricing/error-maxium-acitvation-exceeded.html

    -or https://helpx.adobe.com/x-productkb/policy-pricing/activate-deactivate-products.html

  • Include the expected start Date and end Date for the management of SSHRC-Absence

    Is it possible to include the scheduled Start Date and end Date of project to SSHRC, management of absences with the type of leave is confirmed?

    Thanks in advance

    Hello

    In this case, you should disable the option the absence request, so that by default all sheets are confirmed and the user do not have to apply once leave as planned and then comply.

    You can see the id metalink - "How do I disable the State of Absence of R12 Absence Management Page [ID 786691.1]" to understand how to disable "Planned" option to request authorization for simple customization.

    It will be useful.

    Thank you
    Sanjay

  • date of the current month

    for a date column, I have data for a year

    Suppose I run the query on the month of August, I want to retrieve date during the month of August
    means I want to retrieve the data for the current month.

    This will still take the start date of the current month to the last day of the current month.

    WHERE col  BETWEEN  TRUNC(SYSDATE,'MM') AND LAST_DAY(SYSDATE) 
    
    OR
    
    WHERE col  BETWEEN  TRUNC(SYSDATE,'MM') AND TRUNC(ADD_MONTHS(SYSDATE,1),'MM')-1
    
  • Search based on the start date and end date

    Hello

    I added two fields "Start Date" and "End Date" on a search page.
    I did the VO extension also.
    Now, I have to implement the logic of the search to get all records created between' start' and 'End Date' after pressing the "GO" button on this page.

    Can someone please provide advice to extend the controller.

    Thanks in advance.


    Gaurav.

    I think that the path would be

    Import oracle.apps.per.common.webui.PerTransactionTopCOImpl;

    Thank you
    -Anil
    http://oracleanil.blogspot.com/

Maybe you are looking for

  • How di I uninstall Add-ons blocked FF?

    FF has disabled some add-ons, and I'm unable to uninstall or delete otherwise. How can I get rid of this useless clutter?

  • Replace the SSD 2015 MBP retina

    Purchased the base early 2015 retina MBP (was on a real budget) and I'm looking to replace the SSD with a larger SSD.  I read on various forums that this can be done, but that nobody makes compatible SSD yet... However, these positions have been sinc

  • Windows Wifi problem 8 T61

    When I wake my sleeping T61, hybernation, or if he was arrested with this win8 quick start function, the wifi does not work. It recognizes all wifi networks, but cannot connect to one of them. In order to make it work again I have to either restart o

  • On windows 2008 hyperV Server NETWORK load balancing

    I have IBM Blade servers there team switches running Windows server on HyperV, when I try to configure the NETWORK load on the servers of 2008r2 balancing two Windows LB is not workingworkig?

  • FS NAS CLUSTER cannot join the domain

    FS x 7 series you try to join a nas cluster to the domain and im getting 'cluster already exist in the area, leave the area and join again. I see no traces to it in AD and Group Manager, that it does not leave area it is said that set up AD