How to display each month between the date range

I want a query that gives me the number of months between two dates given for example, if I going January 1, 2009 and April 1, 2009 then I should get on February 1, 2009 and March 1, 2009 in my trips

Thank you very much

Srix wrote:
Thanks for the request

It is not working do not when the effective date is differs from that in a year i.e start date January 1, 2009 and end date February 1, 2009, that it does not give u then required result

I don't know what you mean? The dates are in the same year.

Tags: Database

Similar Questions

  • Get the number of months between the dates.

    Hi I need to get the exact number of months between the dates. So if I'm Sysdate - to_date(31-JAN-2011) I should get something like 8.4 months. Months_between function doesn't quite give me what I need. Is it possible that I can do this?

    876056 wrote:
    Hi I need to get the exact number of months between the dates. So if I'm Sysdate - to_date(31-JAN-2011) I should get something like 8.4 months. Months_between function doesn't quite give me what I need. Is it possible that I can do this?

    I don't see how you get 8.4 months. The counted months are February, March, April, may, June, July, August and, as of today, 9 and change the days of September. Unless I forgot the lessons of counting, I learned in kndergarten is 7 full months and a bit.

    Maybe you want something like:

    SQL> select months_between(Sysdate, to_date('01-JAN-2011', 'dd-mon-yyyy')) mb,
      2         (Sysdate - to_date('01-JAN-2011', 'dd-mon-yyyy'))/30 div30
      3  from dual;
    
            MB      DIV30
    ---------- ----------
    8.27800142 8.38726813
    

    If you get the form date a table, you can use trunc (date_column, 'mm') at the date of the first day of the month.

    John

  • Generating lines separated for each month in a date range

    Basically I have a row of data, for example:

    ID - start_date - end_date

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

    XXA 1/23/14-3/12/14

    And I want to create a line for each month between the arguments start_date and end_date, for each ID, for example:

    ID - month - year

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

    XXA January 2014

    XXA February 2014

    XXA March 2014

    What is the best and most effective way to do it? I thought using a slider, but once the table is created, I need to join the other than this one. I am new to oracle, and I don't know if you can join the other tables after completing a cursor and create a temporary table. Any help would be greatly appreciated.

    so... go with this:

    WITH DATA AS (SELECT "XXA' ID, DATE '2014-01-23' start_date, DATE' 2014-12-03' end_date FROM dual)

    UNION ALL

    SELECT "XX(B)' ID, DATE '2013-05-23' start_date, DATE' 2014-07-03' end_date dual FROM

    UNION ALL

    SELECT "XXC" ID, DATE '2012-01-23' start_date, DATE' 2013-12-03' end_date FROM dual)

    minmax AS (SELECT MIN (TRUNC(START_DATE,'Month')) AS minmon

    MAX (trunc(end_date,'Month')) AS maxmon

    DATA)

    , themons AS (SELECT add_months (minmon, LEVEL - 1) LIKE my)

    OF minmax

    CONNECT BY add_months (minmon, LEVEL - 1)<=>

    SELECT d.id, m.mon

    DATA d

    JOIN themons m ON (m.mon BETWEEN trunc(d.start_date,'Month') AND trunc (d.end_date, 'Month'))

    order by d.id, m.mon

    /

  • Outter Join when you use between the date ranges

    HI -.

    Is someone can you please tell me how I would properly outter join the following statement:

    and trunc (sysdate) between hp.hhold_profile_start_date and hp.hhold_profile_stop_date

    Thank you!

    Hello

    cav0227 wrote:
    HI -.

    Is someone can you please tell me how I would properly outter join the following statement:

    and trunc (sysdate) between hp.hhold_profile_start_date and hp.hhold_profile_stop_date

    What you posted seems to me, assuming you are using the ANSI rating.
    Using the notation on the other, simply add more signs after the column names:

    and     trunc (sysdate)  between  hp.hhold_profile_start_date (+)
                             and      hp.hhold_profile_stop_date (+)
    
  • How to get LASTDAY for each month between data dates...

    Hi friend

    I have a doubt, how to get LASTDAY for each month between data dates...

    for ex:
    My contribution will be like this
    date = 01/12/2011
    To date = 14/04/2011

    And I need an output like
    31/01/2011
    28/02/2011
    31/03/2011

    is it possible to achieve through sql query in oracle
    Thanks in advance for all friends to help him

    Hello

    Something like this (assuming that the dates are originally VARCHAR2s):

    SQL> var dt_start varchar2(10)
    SQL> var dt_end varchar2(10)
    SQL> exec :dt_start := '12-01-2011'
    
    PL/SQL procedure successfully completed
    
    SQL> exec :dt_end := '14-04-2011'
    
    PL/SQL procedure successfully completed
    
    SQL>
    SQL> select last_day(
      2           add_months(
      3             trunc(to_date(:dt_start,'DD-MM-YYYY'),'MM'),
      4             level-1
      5           )
      6         ) as result
      7  from dual
      8  connect by level <= months_between(to_date(:dt_end,'DD-MM-YYYY'), to_date(:dt_start,'DD-MM-YYYY'))
      9  ;
    
    RESULT
    -----------
    31/01/2011
    28/02/2011
    31/03/2011
     
    

    If the dates are already of the date data type, simply remove the to_date function.

  • How to calculate the number of days/weeks/months between 2 dates?

    Hello

    I would like to know how to calculate the number of days/weeks/months between 2 dates in OBIEE 11 g, for example, I have 26/05/2013 and 19/05/2013, then I want to get 7 days.

    Thank you!
    Jamie

    Hi Jamie,

    Through this links...

    http://www.bravesoft.com/blog/?p=682
    http://twobiee.blogspot.in/2012/01/working-with-date-differences.html

    Mark as correct it allows u...
    Thank you...

  • Display the months between two dates

    Hello:
    I need all the months between two dates. I entered two dates as January 15, 2001 and 2011-mar-03. I want the result as below.

    JANUARY 15, 2011 - JANUARY 31, 2011
    February 1, 2011 - February 28, 2011
    MARCH 1, 2011 - MARCH 3, 2011

    I held this result of sql query in oracle. Could you please suggest me?
    Thanks in advance.
    Abhishek
    SELECT     GREATEST(st, ADD_MONTHS(TRUNC(st, 'MONTH'), (LEVEL - 1))) dt,
               LEAST(ed, LAST_DAY(ADD_MONTHS(TRUNC(st, 'MONTH'), (LEVEL - 1)))) ld
          FROM (SELECT DATE '2011-01-15' AS st, DATE '2011-03-03' AS ed
                  FROM DUAL)
    CONNECT BY LEVEL <= MONTHS_BETWEEN(TRUNC(ed, 'MONTH'), TRUNC(st, 'MONTH')) + 1
      ORDER BY 1;
    
    DT                       LD
    ------------------------ ------------------------
    15.01.2011 00:00:00      31.01.2011 00:00:00
    01.02.2011 00:00:00      28.02.2011 00:00:00
    01.03.2011 00:00:00      03.03.2011 00:00:00
    

    HTH, Urs

  • How do the 3rd week (business day) of the month in a date range?

    Hello


    I'm trying to find the 3rd day of the work week of each month in a given range of dates.  How is it possible in a SQL query? Thank you in advance.

    Hello

    Here's one way:

    SELECT first_day + BOX

    WHEN TO_CHAR (first_day, "DY") IN ("play", "Fri", "SAT")

    THEN 4

    WHEN TO_CHAR (first_day, "DY") ("SUN")

    THEN 3

    2 ELSE

    END AS workday_3

    DE)

    SELECT ADD_MONTHS (first_month

    , LEVEL - 1

    ) AS first_day

    DE)

    SELECT TO_DATE ('Sep 2013', 'My YYYY') AS first_month

    , TO_DATE ('Jan 2014', 'Mon YYYY') AS last_month

    OF the double

    )

    CONNECT BY LEVEL<= 1="" +="" months_between="" (last_month,="">

    )

    ORDER BY workday_3

    ;

    In another thread,.

    https://community.Oracle.com/thread/3513808

    you said that you had problems using a WITH clause, so I used online views instead of CLAUSES.

    With the above parameters, the result is:

    WORKDAY_3

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

    Wed 04-Sep-2013

    Set of 3 October 2013

    November 5, 2013 Mar

    Wednesday, December 4, 2013

    Fri January 3, 2014

  • 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

  • How to write a query for the data exchange between two columns?

    How to write a query for the data exchange between two columns?

    I tried a request, does NOT work.
    update tmp t1 set t1.m1=t1.m2 and t1.m2=(select t2.m1 from tmp t2 where t2.student_id = t1.student_id)
    Thank you.

    Published by: user533361 on October 23, 2009 14:04

    Just plain and simple:

    update tmp t1
     set t1.m1=t1.m2,
         t1.m2=t1.m1
    /
    

    SY.

  • Months between two dates

    Hello

    I have two dates. start date and end date.

    I want to extract months between two dates

    months should be as

    JAN

    FEB

    MAR

    for example.

    Start - 1-jan-2014

    date of end - 31 - dec - 2014

    How can I do this?

    Thanks and greetings

    CORINE

    You should always use the function MONTHS_BETWEEN...

    for example

    SQL > ed
    A written file afiedt.buf

    1 with t as (select date '' 2014-01-01 as start_date date ' 2014-12-31' as double end_date)
    2  --
    3 end of test data
    4  --
    5. Select to_char (add_months (start_date, rownum-1), 'My') by month
    6 t
    7 * connect by rownum<=>
    SQL > /.

    LUN
    ---
    Jan
    Feb
    Mar
    Apr
    May
    Jun
    Jul
    Aug
    Ms
    Oct
    Nov
    Dec

    12 selected lines.

    And if you want that they display, separated by commas...

    SQL > ed
    A written file afiedt.buf

    1 with t as (select date '' 2014-01-01 as start_date date ' 2014-12-31' as double end_date)
    2  --
    3 end of test data
    4  --
    5 Select listagg (to_char (add_months (start_date, rownum-1), 'My'), ',') group by month (order by rownum)
    6 t
    7 * connect by rownum<=>
    SQL > /.

    MONTH
    -----------------------------------------------------------------------------------------------------------------
    Jan, Feb, Mar, Apr, may, June, July, August, Sept, Oct, Nov, Dec

  • Insert record monthly between certain dates

    Hi all

    Any help is very appreciated.

    I would like to add records to a table every month according to certain dates. So I'll have a start_date and end_date and I would like to add a record to a table the 1st of each month between these two dates.

    Can you please let me know what would be the best way to address the issue and give an example of the code please.

    Thank you

    Hello

    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables.
    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
    If you ask on a DML statement, such as CREATE TABLE, INSERT, INSERT statements must re-create the tables as they are to the DML, and the results will be the content of the or a modified tables when it's all over.
    Always tell what version of Oracle you are using.

    Here's one way:

    INSERT INTO table_x (due_date)
    WITH    parameters  AS
    (
         SELECT     DATE '2011-10-01'     AS start_date
         ,     DATE '2012-03-31'     AS end_date
         FROM     dual
    )
    SELECT     ADD_MONTHS ( TRUNC (start_date, 'MONTH')
                  , LEVEL - 1
                 )
    FROM    parameters
    WHERE     ADD_MONTHS ( TRUNC (start_date, 'MONTH')
                  , LEVEL - 1
                 ) >= start_date
    CONNECT BY     LEVEL     <= 1 + MONTHS_BETWEEN ( TRUNC (end_date,   'MONTH')
                                          , TRUNC (start_date, 'MONTH')
                                   )
    ;
    
  • Recurring appointment Set for certain days of the week each month in the calendar on Surface RT?

    It seems to me that this is not possible, but is there a way I can put a recurring appointment for a certain day of the week of each month in the calendar on the Surface RT? For example, a meeting Tuesday on two or one excursion each fourth Sunday?  I know that this is possible in Outlook on a PC and I would like to do it on the Surface RT as well.  Most of my recurring appointments are of this type.  When I recur every month on the Surface, it just sets it for the same date (for example the 12th of each month) instead of the second Tuesday.  Thank you!

    Hi Lisa,

    You were correct when you say that 'it seems to me that's not possible. ' The recurring appointment for some day of the week each month in the calendar on Surface RT cannot be done by date and not day.

    Good day!

  • How to change each color of the illustrator vector object in 2013 of PowerPoint?

    When my client want different colors on vector graphical objects in PowerPoint.

    For example, I created graphics in Adobe Illustrator CS6 element, and then save as .emf file with color RGB, once exported mode then I insert the image from that file in PowerPoint 2013, after that I used separate both times. When I click on the different color theme, but it has not changed color.

    See video screenshot: 2015-10-03_1414 - fatech library

    I'm trying to understand how to change each color of the illustrator vector object in 2013 of PowerPoint? Please help me!

    Thank you

    FATECH wrote:

    But I want other options...

    There is no all.

    Illustrator and MS-Office share not all the graphics features of construction at the file level. There is no universal edit-ability between the two.

    .. which is the best export (eps, emf, or svg), then insert a vector file into PowerPoint?

    If your Illustrator illustration is vector of 100% and contains no live effects, complex gradients, blends, etc., the first thing to try is copy > paste special > enhanced metafile.

    Otherwise, SPE may work, or you can use the pixelation in PNG. Personally, I do not consider export raster format Illustrator to be a stable workflow method, so I'd be inclined to use Photoshop as an intermediate step: Illustrator > Save As PDF > open in Photoshop > save in PNG. Just my preference.

  • Strange problem casting between the DATE and time STAMP

    Hello world

    I'm faced with a problem of strange casting between the DATE and time STAMP. Strange, because this happens in SQL-Developer and the Testdatabase, but not when called from inside SQL-Plus, even if all Session settings are set to the top completely equal.

    I work on the Oracle 11 g Enterprise Edition Release 11.2.0.1.0 Windows database and run the following script, taken from SQL-Developer script output:

    < pre >
    create table ts_test)
    time/date stamp,
    stamp_copy timestamp)
    table TS_TEST standing.

    create or replace view vw_test as
    Select cast (date stamp) buffer,
    Cast (stamp_copy as date) stamp_copy
    of ts_test
    view VW_TEST standing.

    insert into ts_test
    Select systimestamp, the double null
    1 eingefugt Zeilen.

    Commit
    festgeschrieben.

    create or replace trigger trg_ts_test_iu
    instead of update on vw_test
    Start
    Update ts_test
    Set stamp_copy =: new.stamp_copy;
    end;
    RELAXATION trg_ts_test_iu kompiliert

    Update vw_test
    Set stamp_copy = stamp
    1 Zeilen written on.

    Select the stamp, stamp_copy, dump (stamp_copy)
    of ts_test
    STAMP STAMP_COPY DUMP (STAMP_COPY)
    -----------------------------------------------------------------------------------------------------------------
    30.05.2012 19:08:49, 218000000 30.05.3192 20:09:50, 000000000 Typ = 180 Len = 7: 131,192,5,30,21,10,51

    Select *.
    of nls_session_parameters
    VALUE OF THE PARAMETER
    ----------------------------------------------------------------------
    NLS_LANGUAGE GERMAN
    NLS_TERRITORY GERMANY
    NLS_CURRENCY €
    NLS_ISO_CURRENCY GERMANY
    NLS_NUMERIC_CHARACTERS.
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT exact hh24:mi:ss
    NLS_DATE_LANGUAGE GERMAN
    NLS_SORT GERMAN
    NLS_TIME_FORMAT HH24:MI:SSXFF
    NLS_TIMESTAMP_FORMAT JJ. MM YYYY HH24:MI:SSXFF
    NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT JJ. MM YYYY HH24:MI:SSXFF TZR
    NLS_DUAL_CURRENCY €
    BINARY NLS_COMP
    NLS_LENGTH_SEMANTICS TANK
    NLS_NCHAR_CONV_EXCP FAKE

    17 Zeilen offiziell

    Rollback
    Rollback abgeschlossen.
    < / pre >

    Look at the strange data that stamp_copy was after the update.

    When run from SQL over, everything is fine. But when I run this code in our application, the same phenomenon occurs. I've even seen a data dating back to the year 11907 (!), giving an exception by selecting from the table.

    Someone at - it an idea on how to work around this bug?

    Best regards

    Jürgen

    Did you check metalink for bugs?

    There are a few listed in this blog, that may be useful for you.

    http://hoopercharles.WordPress.com/2011/02/17/strange-timestamp-behavior/

Maybe you are looking for

  • WHY MAKE TWO COPIES OF EMAILS THAT I SEND IN MY OUTBOX

    SAME AS MOST HIGH: WHY MAKE TWO COPIES OF EMAILS THAT I SEND IN MY OUTBOX

  • Satellite M30X-159 - laptop crashes + USB problem

    I bought my M30X in February, in April, all 3 USB ports failed. I tried to install the update to the Bios, reformatted nothing doesn't. In may, the motherboard has been replaced. Yesterday, I used a memory stick once again, and while the two USB port

  • Streaks M551

    I have a customer with a M551 leaves streaks on the page.  Here's what I found: -The streaks are black -Streaks are very wide and dark when the printer has not been used for a few days and greatly improves with multiple page printing -All ink cartrid

  • Contacts transfer blackBerry to Android Smartphones

    My wife has a Motorola Moto G (2nd generation) and I would get all the contacts of my Torch 9860 (BB7) transferred to his phone.  How can I do this without having to buy a PMK program? FYI, some forums Google offers Google Sync, which seems to no lon

  • BlackBerry Smartphones Mute key error

    Mute the button on top of my curve used to disable my BlackBerry When I put it in its case. Now mute the button has stopped working and it will not disable. How can I get this working again?