REQ: script to calculate the number of months

Looking for a script that will calculate the number of months between 2 dates (to 2 decimal points)

or if there is a way to make a calculation of the number of months

for example: if I go to google and say 75 days - months, it returns a value of 2.46

That's what I'm looking for

If anyone can help?

with a calculation of date or number calculation?

I tried # days / 365 x 12 but there is no decimal places.  right guard rounded up/down

As mentioned in a month, the days are not constant throughout the year and change formula 28-31 days. How are you calculating the decimal value of the month?

A year has 365 days, if she did then there would be no need for leap years and centuries jump.

Calculation of a variable with the result of a calculation method is set to decimal.

cDateFormat = "d-mmm-yyyy";
var cStartDate = "January 1, 2000;
var oStartDate = util.scand (cDateFormat, cStartDate);
oStartDate.setHours (0, 0, 0, 000);
var cEndDate = "January 15, 2000;
var oEndDate = util.scand (cDateFormat, cEndDate);
oEndDate.setHours (0, 0, 0, 000);
nDiff var = oEndDate.getTime () - oStartDate.getTime ();
Console.println ("end date:" + cEndDate);
Console.println ("start date:"+ cStartDate ");
Console.println ("difference in milliseconds:" + nDiff);
Console.println ("difference in seconds:" + nDiff/1000);
Console.println ("difference in minutes:" + nDiff / (1000 * 60));
Console.println ("difference in hours:" + nDiff / (1000 * 60 * 60));
Console.println ("difference in days:" + nDiff / (1000 * 60 * 60 * 24));
Console.println ("difference in weeks:" + nDiff / (1000 * 60 * 60 * 24 * 7));
Console.println ("difference over the years:" + nDiff / (1000 * 60 * 60 * 24 * 365.2524));
Console.println ("difference in months:" + nDiff / ((1000 * 60 * 60 * 24 * 365.2524) / 12));  12 months in a year;

End date: January 15, 2000
Start date: January 1, 2000
Difference in milliseconds: 1209600000
Difference in seconds: 1209600
Difference in minutes: 20160
Difference in hours: 336
Difference in days: 14
Difference of weeks: 2
Difference in years: 0.0383296591617194
Difference in months: 0.45995590994063273

Several turncate the decimal values scirpts because keeping them may not meet the need of specific calculation. You know that there are methods to roud until the next iniger, round.5 to the top and turnacate to the lower intiger.

According to the date of departure, the values may be different:

For a start date of February 1, 2000, 75 days would be 1,810 months but for a start date of 1 February 2001 75 days becomes 1,838 since the number of days of changes of February 29 to 28 and the number of days for the month of fractions varies from 26 to 27.

Tags: Acrobat

Similar Questions

  • Calculation of the number of months

    Hi guys,.

    How to calculate the number of months between two dates

    Opening date: 20/02/2014

    Closing date: 20/03/2015

    Terms of months: 13

    How I get the year and subtract and multiply by 12 and then add it to the difference of the month? Sorry that I am not well versed in the scripts.

    Thanks in advance.

    In this way, you have provided the example. You can change the constant string to the necessary code to get the value of a field. You can add additional to prevent code by using the code until the two fields have a non-null value.

  • Calculate the number of days between two dates

    Hello

    Can someone help please change my formcalc script to calculate the number of working days between two date fields.  My script currently calculates the total number of days between two dates, including the weekends which must be excluded from the total.

    If

    (HasValue (Start_Date1) & HasValue (End_Date1)) then

    $

    = Date2Num (End_Date1, "YYYY-MM-DD" "en_IE") - Date2Num (Start_Date1, "YYYY-MM-DD" "en_IE") + 1

    on the other

    ""

    endif

    Any help will be most appreciated.

    Thank you.

    Check...

    (1) you said that you put the script on the event «days1» calculate My sample imitates the variable names used in the original message, "Start_Date1" and "End_Date1". If the names of variables for the start and end dates are different, you will need to modify the script to account for these names.

    (2) the Date2Num functions in the calculation of the "totalDays" use the date format "YYYY-MM-DD". If your date habits differ from "YYYY-MM-DD" FormCalc will complain.

    Steve

  • 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...

  • Gets the number of months to a Date

    Hello

    I use the version of database Oracle 11.2.1. I would like to calculate the number of fiscal month of a date.

    For example:

    Date: 31/03/2013
    Fiscal No. month: 12

    The fiscal year runs from 01 - Apr-31 - March each year.

    Hello

    You can use

    EXTRACT (MONTH FROM (ADD_MONTHS (mydate, -3)))
    

    Example:

    WITH mytable AS (    SELECT TRUNC(SYSDATE) - 400 + LEVEL mydate
                           FROM DUAL
                     CONNECT BY LEVEL <= 400)
    SELECT mydate, EXTRACT (MONTH FROM (ADD_MONTHS (mydate, -3))) fiscal_month
      FROM mytable
     WHERE mydate = TRUNC (mydate, 'MM')
        OR mydate = LAST_DAY(mydate);
    
    MYDATE    FISCAL_MONTH
    --------- ------------
    31-MAR-12           12
    01-APR-12            1
    30-APR-12            1
    01-MAY-12            2
    31-MAY-12            2
    01-JUN-12            3
    30-JUN-12            3
    01-JUL-12            4
    31-JUL-12            4
    01-AUG-12            5
    31-AUG-12            5
    01-SEP-12            6
    30-SEP-12            6
    01-OCT-12            7
    31-OCT-12            7
    01-NOV-12            8
    30-NOV-12            8
    01-DEC-12            9
    31-DEC-12            9
    01-JAN-13           10
    31-JAN-13           10
    01-FEB-13           11
    28-FEB-13           11
    01-MAR-13           12
    31-MAR-13           12
    01-APR-13            1
    

    Kind regards.
    Al

  • Calculate the number of fringes

    Is anyone know the feasibility of the use of the Machine Vision or LabView to calculate the number of fringes in each region? (Attached image). I want to count how many white line on each region. For example, on the attached picture, there are about 6 regions and each region will display the number of the white line in their own region. For information, I have V8.5 of LabView and NI Vision Assistant V8.5. Please, give me some ideas on how to solve it.

    Thank you.

    Farid

    Check this box

  • Calculate the number of days remaining until the next anniversary. Help, please!

    Hi guys,.

    I'm new to the forum and to the development of BB. So please do not judge harshly if the answer to my question seems obvious.

    I need to calculate the number of days until the next birthday (taking into account any valid birth date)

    After looking at the API and the forum search, I realized that I could

    calculate the difference between two dates in milliseconds and then divide the delta of the value of a day in milliseconds. That is to say:

    birthdayCalendar.set (Calendar.YEAR, those);

    Date1 = birthdayCalendar.getTime () .getTime ();

    date2 = System.currentTimeMillis ();

    Delta = date1 - date2

    numOfDays = delta\DateTimeUtilities.ONEDAY

    Here's my question. How do I create a valid date1 what about leap years?

    Maybe there's a better way to solve this problem?

    Any help is greatly appreciated.

    I agree that the determination of the number of days between today and Feb. 29 could be a little difficult, if it is not a leap year.  I suspect that the calendar has a certain built-in mechanism to compensate for this, but your solution to choose a date is better.

    DST has a role to play, and Yes, the calendar makes up for it.  Let us take two dates, for example (before DST) March 1 and June 1 (after the DST).  If you take a calendar and set the same hour, minute, etc., they are all the same except for dates, then subtract one from the other, and then divide by the number of milliseconds in 1 hour, you calculate the number of hours between the same time on two different days.  You will find that it is not a multiple of 24 hours - because there is actually an hour less than the number of days since the clocks move forward (in the northern hemisphere anyway...),

    In your case, you are not calculating the number of hours, you calculate the number of days.  But you will be dividing by [24 * (time in an hour)].  If you take [23 * (time in an hour)] and divide it by [24 * (time in an hour)], using arithmetic on integers, you will end up 0.  The easiest to get around this, who also works for the end of the DST too, is to simply add one hour to the date before the division.

    Hope that makes sense...

  • How to calculate the year last month in obiee 11g?

    Hello

    I want to calculate the year last month in obiee 11g. I tried DB.

    -SELECT TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYYMMDD') FROM DUAL;

    Using the above query, year last month is -"08-01-2015"

    But I want to get the same result using timestampadd() in obiee 11g.

    Please help me,

    Thanks in advance,

    A.Kavya

    Hello

    TIMESTAMPADD (SQL_TSI_YEAR-1, CURRENT_DATE)

  • Essbase calc script to determine the number of occurrence

    Hello

    is it possible within a calc script to determine the number of occurrence of a value in the account dimension?

    I have an account called ranks which can contain any value between 1 and 10.  I would like to know how many times each value is repeated for a specific cost center.  It's in a database of planning BSO.

    Thanks in advance for your contributions...

    CL

    This isn't the typical calculation you would do in an OLAP architecture, but yes it is certainly possible.

    you will need to create 10 accounts such as occurrence_of_1, occurrence_of_2 etc.

    Then you increment them according to the value of the 5th year.

    Don't forget to put in your calculation!

  • Count of the number of months with unpaid for the last six months

    Hello

    I now table to store the daily presence of each employee

    ATTENDANCESHEET

    EMPID

    PAYROLLDATE

    UNPAID

    1

    10/01/2013

    6

    1

    10/02/2013

    2

    1

    11/01/2013

    0

    1

    11/02/2013

    0

    1

    12/01/2013

    0

    1

    12/02/2013

    0

    1

    01/01/2014

    0

    1

    01/02/2014

    0

    1

    02/01/2014

    0

    1

    02/02/2014

    0

    1

    03/01/2014

    45

    1

    03/02/2014

    0

    2

    03/01/2014

    0

    2

    03/02/2014

    0

    I want to get the number of months used unpaid in the past 6 months (excluding the current).

    If the month of payroll, I'm in treatment is 4, 2014, I spend 4 as payrollmonth and 2014 as payroll year

    The application must check the latest 6 month data and number of months for which there is any unpaid value

    In the case above for month 4, 2014, the power required is

    EmpID

    County

    1

    2

    2

    0

    I use oracle 10g

    EXAMPLES OF DATA

    create the table attendancesheet as

    (

    Select 1 as empid, to_date (January 10, 2013 ',' DD/MM/YYYY ') as payrolldate, 6 paid by union double all the

    Select 1 as empid, to_date (10 February 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (January 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (12 January 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 12, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (1 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 1, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (January 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 45 paid by union double all the

    Select 1 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 2 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 as default all the double union

    Select 2 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid double

    );

    Help, please

    Hello

    So, you want to count the distinct months for 6 months before (not included) the given month; is this fair?

    Here's one way:

    VARIABLE month VARCHAR2 (2)

    Year VARIABLE VARCHAR2 (4)

    EXEC: months: = '4';

    EXEC: year: "2014"; =

    WITH got_end_date AS

    (

    SELECT TO_DATE (: month |) '/' || : year

    , ' MM/YYYY ".

    ) AS end_date

    OF the double

    )

    SELECT a.empid

    , COUNT (DISTINCT

    CASE

    WHEN a.unpaid > 0

    THEN TRUNC (a.payrolldate, 'MONTH')

    END

    ), Cnt

    Of attendancesheet one

    JOIN e-got_end_date WE a.payrolldate > = ADD_MONTHS (e.end_date-6)

    AND a.payrolldate< >

    GROUP BY a.empid

    ORDER BY a.empid

    ;

    If you use a WHERE clause to exclude the lines with some outstanding = 0 (or unpaid is NULL), then you would get no output for employees like empid = 2 in this example.  A WHERE clause ignores an entire line, so I used an expression BOX just a value.

  • Basic conditional script based on the number of lines in a text layer?

    Just received help here to write a conditional script by using the font size of a text layer. Thank you all for this.

    The next hurdle is a conditional script using the number of lines in a text layer in the differential. Far as I can tell it not the layer details which specify the number of lines. Just '\r' for a return in the idTxt descriptor. Nothing seems to stand for a soft return as far as I can tell. I'll probably have to be able to count the lines with soft and hard returns.

    Any thoughts?

    I was playing around with this a bit and here is a small script to determine the number of rows. This is based on the self in the head, that I calculated to environ.108 times the size of the font.

    #target photoshop
    app.preferences.rulerUnits = Units.POINTS;
    var doc = activeDocument
    var tL = doc.activeLayer
    var h = tL.bounds[3]-tL.bounds[1]
    var per = ((h/5)-(tL.textItem.size))/tL.textItem.size
    var num = h/(tL.textItem.size *1.108)
    
    alert(Math.round( num))
    
  • calculate the last 5 months

    How to calculate the final 5 months of sysdate?

    Education - TO_CHAR(SYSDATE,'YYYYMM')-1 SELECT FROM DUAL gives 201300. The desired output is 201212, 201211, 201210, 201209 201208.

    Sanjay

    Try this

    select to_char(add_months(sysdate, -1), 'YYYYMM') from dual
    union
    select to_char(add_months(sysdate, -2), 'YYYYMM') from dual
    union
    select to_char(add_months(sysdate, -3), 'YYYYMM') from dual
    union
    select to_char(add_months(sysdate, -4), 'YYYYMM') from dual
    union
    select to_char(add_months(sysdate, -5), 'YYYYMM') from dual
    
  • Select the number of months (NULL and non-null separated)

    -Table_1
    -------------

    create table_1
    (
    Arrival_Date DATE
    Counter_seq number (*) not null,
    Exclusion_type varchar2 (10)
    )

    -INSERTION
    -------------

    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 1,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 2, 'PAW');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 3, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 4,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 5,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 6, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 7,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 8, 'PAW');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 9, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 10,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 11, 'PAW');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 12, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 13,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 14,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 15,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 16,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 17,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 18,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 19, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 20,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 21,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 22,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 23,"HAN");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 24,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 25,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-DEC-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 26,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 27,");


    -SELECT THE NUMBER OF MONTHS
    --------------------------------------

    SELECT EXCLUSION_TYPE,
    County (decode (to_char (ARRIVAL_DATE, 'MON-YYYY'), "DEC-2009", COUNTER_SEQ ")) dec09,.
    County (decode (to_char (ARRIVAL_DATE, ' MON-YYYY ""), "JAN-2010", COUNTER_SEQ ")) Jan10.
    County (decode (to_char (ARRIVAL_DATE, 'MON-YYYY'), ' Feb-2010 ", COUNTER_SEQ")) Feb10
    FROM TABLE_1
    EXCLUSION_TYPE GROUP;


    -CHOOSE IT ABOVE RETURENS: -.
    ------------------------------------------------


    EXCLUSION_ DEC09 JAN10 FEV10
    4 4 4
    0 3 4 LEG
    HAN 3 2 0


    My question is, I need to select a month ruturning one row of NULL values and a line of values not null. Like that so all right: -.

    EXCLUSION_ DEC09 JAN10 FEV10
    Exclusion_Type 4 4 4 NULL
    Exclusion_Type Not null 3 5 4

    The ideas people?

    Published by: Deeds_2001 on November 16, 2010 12:47 AM
    SQL> SELECT DECODE(exclusion_type,NULL,'NULL','NOT NULL') exclusion_type,
      2  COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'DEC-2009', counter_seq)) Dec09,
      3  COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'JAN-2010', counter_seq)) Jan10,
      4  COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'FEB-2010', counter_seq)) Feb10
      5  FROM table_1
      6  GROUP BY DECODE(exclusion_type,NULL,'NULL','NOT NULL');
    
    EXCLUSIO      DEC09      JAN10      FEB10
    -------- ---------- ---------- ----------
    NULL              4          4          4
    NOT NULL          3          5          4
    
    SQL> 
    
  • Get the number of month, week and day between 2 dates

    Hi all

    Is it possible to display the number of months, weeks and days between 2 dates? by using only the SQL or PL/SQL...

    Entry:
    Date: October 1, 2010
    Date: October 19, 2010

    I want output like below (assuming starts the week from Monday to Sunday in oracle).

    October 1, 2010-(since it's in the middle of the week)
    October 2, 2010-(since it's in the middle of the week)
    October 3, 2010-(since it's in the middle of the week)
    40. (4 Oct-10 Oct falls into the 40th week of the year)
    41. (11 Oct-17 Oct falls into the 41st week of the year)
    October 18, 2010-(since it's in the middle of the week)
    October 19, 2010-(since it's in the middle of the week)


    Note: If there is a month between the date, the number of the month should be displayed.
    End of the month, the remaining date included with a full week, then the week of the year number should
    displayed. After posting the week, remaining dates should be displayed as it is...


    Appreciate your help...



    Thank you.
    Fox.

    You mean something like this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  WITH t AS (select date '2010-09-27' as fdate, date '2010-11-21' as tdate from dual)
      2  --
      3  -- END OF TEST DATA
      4  --
      5  select dt2
      6  from (
      7        select dt,
      8               case when days_of_mn = days_in_month then 'Whole: '||to_char(dt,'Month')
      9                    when days_of_wk = 7 then 'Week: '||to_char(dt,'fmWW')
     10               else to_char(dt, 'DD-fmMonth-YYYY')
     11               end as dt2
     12              ,row_number() over (partition by
     13                 case when days_of_mn = days_in_month then to_char(dt,'Month')
     14                                  when days_of_wk = 7 then 'Week: '||to_char(dt,'fmWW')
     15                 else to_char(dt, 'DD-fmMonth-YYYY')
     16                 end order by dt) as rn
     17        from (
     18              select dt, wk, mn, days_in_month
     19                    ,count(*) over (partition by wk) as days_of_wk
     20                    ,count(*) over (partition by mn) as days_of_mn
     21              from (
     22                    select fdate+rownum-1 as dt
     23                          ,to_number(to_char(fdate+rownum-1,'fmWW')) as wk
     24                          ,to_number(to_char(fdate+rownum-1,'fmMM')) as mn
     25                          ,to_number(to_char(last_day(fdate+rownum-1),'fmDD')) as days_in_month
     26                    from t
     27                          connect by rownum <= tdate-fdate+1
     28                   )
     29             )
     30        ) x
     31  where rn = 1
     32* order by dt
    SQL> /
    
    DT2
    -----------------
    27-September-2010
    28-September-2010
    29-September-2010
    30-September-2010
    Whole: October
    Week: 44
    Week: 45
    Week: 46
    19-November-2010
    20-November-2010
    21-November-2010
    
    11 rows selected.
    
    SQL>
    
  • Calculate the previous three months

    I want to calculate the past 3 months on the basis of sysdate in 3 separate columns. I get the previous month by executing the following SQL statement:
    select EXTRACT(MONTH FROM TRUNC(SYSDATE,'MONTH')-1)mn1 from dual
    The current month is July, then how can I get 05, 04 as output.

    Yogesh

    Hello

    Just remove TRUNC...

    select EXTRACT(MONTH FROM (SYSDATE))-1 mn1,EXTRACT(MONTH FROM (SYSDATE))-2 mn2,EXTRACT(MONTH FROM (SYSDATE))-3 mn3 from dual;
    

    AJ

Maybe you are looking for