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

Tags: Database

Similar Questions

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

  • Hello I get in touch with you because I have passed a Bill, and gave me the bottom three months ago and I want my money thanks

    Hello I get in touch with you because I have passed a Bill, and gave me the bottom three months ago and I want my money thanks

    Hello Monica,.

    Please contact support by calling/chat for claims.

    Contact the customer service

    Kind regards

    Sheena

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

  • How to calculate the percentage of monthly sales

    Hello

    I have a column sales of the month and I have another column that calculates (monthly sales / (total number of monthly sales)) * 100.

    How to calculate this percentage of sales.

    Please advice.

    Kind regards

    Séverine.

    You can use the AGGREGATE function for the TOTAL monthly sales in the year:

    Something like: AGGREGATE ("measure monthly sales" to "Time" ".") Time hierarchy ".» An »)

    Calculate your final formula:

    "measure the monthly sales" / AGGREGATE ("measure monthly sale 'to"time'." Time hierarchy ".» Year') * 100

  • emails from the last three months disappeared from the Local folder on the iMac

    All of my emails go to the folder "Mail" in the local folders. Two days ago I noticed that all mails since at least the beginning of the year has disappeared. I use the iMac Time machine, but cannot see the library on the external hard drive that I can restore. Where I can watch, and why did it happen?

    http://KB.mozillazine.org/Disappearing_mail

    You compact your folders frequently?
    http://KB.mozillazine.org/Keep_it_working_-_Thunderbird

  • LifeLog only show the past 3 months of data.

    My Lifelog is only show my data in the last three months. Can someone please?

    Thank you very much.

  • Why all the BSOD? More in the last 10 days than the last 10 months

    All of a sudden in the last 10 days, my PC has been constantly stop, a few automatic reboots [I know because Google Chrome, Opera & Internet Explorer all ask what I want to open the pages who suddenly disappeared]. Others showing the BSOD of different color...

    Sometimes I got BSOD too, although on these occasions, it was not the old blue screen dark with a myriad of writing, instead a lighter blue screen telling me to stop, the evidence gathered [to up to 100% and then auto shut off and reboot]' the last 3 times there have been various error messages invited me to do a search on the internet for the answer...

    IRQL_NOT_LESS_OR_EQUAL

    DRIVER_POWER_STATE_FAILURE

    KERNEL_DATA_INPAGE_ERROR

    I did a bit of googling, found at Microsoft support group where others have been invited to copy, the minidump zip files and upload to skydrive; what I've done; the zipped file is available for reading... but do not have done this before. I'm not sure of the next step... I tried to simply enter answers.microsoft.com in the municipality filed, but it was not acceptable...

    If I had to guess, in the previous six months before the current problems, I doubt that there are 2 episodes of BSOD stop.

    I am running windows 8.1 completely up to date and it's really p * sing me OFF... others may say their system starts up quickly, and I confess that I have 3 or 4 drives external storage, and I use Acronis as a safeguard measure after the last time I had to reload Windows [due to a failed update]... but after BSOD today... I timed it the beginning upward and it took 1 min 45 sec as soon as the start screen first showed... when the blocked password login screen appeared... so I want this issue fixed! PLEASE...

    Chris

    There are 3 different causes, but according to me, there is an underlying problem.  Please run the Driver Verifier to find which driver he is

    These accidents were related to the corruption of memory (probably caused by a driver).

    Run these two tests to check your memory and find which driver is causing the problem.  Launch auditor.  You don't need to run memtest again unless the auditor is not the cause, or you want to.

    If you are overclocking anything reset by default before running these tests.
    In other words STOP! If you don't know what it means that you're probably not  


    1-Driver Verifier (for full instructions, see our wiki here)

    2-Memtest. (You can learn more about running memtest here)
  • How to view the last 12 months of data in dashboards OBIEE 11 g?

    I need to create a report to show a metric for the last 12 months... How can I do that exactly?

    I know I should use the TimeStampAdd() function, but it does not somehow for... Please list me the details step by step if possible (filters, syntax, PivotTable).

    I'm basically pulling in a column of calendar month (e.g. YYYY / MM - 2014 / 01) and the quantity ordered (column of fact).

    Thank you

    Pat

    Hello

    Thanks for the reply... I think I got it however.

    Done via a pivot table... and he showed me the previous 12 months.

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

  • After three months of data

    Hello
    I need to display data from the course of the last three months, maybe by using a filter or function in Oracle BI response. Is there someone who can help me with this? Your solution will be highly appreciated!

    Thank you.

    Jin
    Use this solution in the filter condition

    TIMESTAMPADD (SQL_TSI_MONTH,-3, time.) ("" Current date ")

    where Time. "" Current date "is your date column

    Thank you
    saichand.v

  • Difficulty accessing data by using the function of Ago - the end of the previous month

    Hey,.

    Recently, I met a problem that I can't fix on my own.


    I need to compare my portfolio to the current date / specified with the portfolio for intelligence and for the end of the previous month (the last day of the previous month).

    It looks like this :

    Capture.JPG

    My fact table consists of the list of contracts of loan that is updated daily. The data for the new day are added to the table, which actually resemble a large sandwich of various portfolios.


    To recover the data for the current/specified date and intelligence is not a problem. Current date - the date is read (can 10.08.2014), the day before - I use the Ago function (e.g., 09.08.2014).

    The real problem is getting the data for the last day of the month previous (e.g. 31.07.2014), since I can't put a specific to the function of Ago offset (10 days in our example), as the number of days from the end of the previous month is constantly - changing is a daily report.


    The best solution would be setting the offset function there is a dynamic value, which would change according to the user selects the date of the report. Can be based on the number of days in the month. BI strictly prohibits using anything that is not an integer in the offset value, so this isn't an option.


    I tried a work around using formulas in columns, like: FILTER ('facts of agreements'. "" Outstanding "USING ("Posting Date". "" Id of the day ' = TIMESTAMPADD (SQL_TSI_DAY, TIMESTAMPADD (1), (SQL_TSI_DAY, 'Date of Report'.) "Number of the day in the month" *-(1) + 1, DATE ' @{report_date}'))). "

    It did not work, since the data I receive are dated the last day of the previous month and date, which is applied to get the data for the current date filter / specified, it cuts.


    Tried to create another time the hierarchy, with the ends of period (week, month, quarter, year) and use it as a level at the Ago. He does work in part, offset the end of 1 month, but I can't bind the data, I get to the date of the report, as the Ago function returns random dates.


    I tried to search if people have had the same problems and it seems I'm the only one. I'm really desperate at this point, not even sure it's possible to get the result I need everything.

    So, please advise!


    Aurore

    Finally got sorted! Hoorey!

    Here's how it's done:

    I created a presentation variable 'report_date' for the user to choose the date of the desired report. That this formula has added to the column:

    FILTER ('facts of agreements'. "" Outstanding "USING ("facts of agreements". (("" Days late max "> 30))-there is (FILTER ('facts of agreements'. "" Outstanding "USING ("facts of agreements". ((("" Days late max "> 30)), TIMESTAMPDIFF (SQL_TSI_DAY, TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (DATE ' @{report_date}') *-1, DATE ' @{report_date}" "), DATE ' @{report_date}'))

    Basically, this formula is used to calculate the difference between the current amount of the portfolio and the amount of portfolio for the last day of the last month (or at the end of last month), where only loans with number of days late over 30 are included.

    In the service there, I used a TIMESTAMPDIFF as a compensation formula to calculate the difference in days between the date of the report and the end of last month. Now no matter what date the user chooses it will give the correct difference in days.

    Really easy, but it took me a little time to get there.

    Hope this helps someone

  • How to calculate the month on month growth rates in an OBIEE application?

    Hi all

    I would like to ask for your help on how to calculate the months on growth rate previous/[(last month-previous month) month * 100%] in a query OBIEE. This report should always be calculated for the last 2 months available.

    I have the following query:
    Month0 | Months1. Month2
    Produces a 500 | 100. 200
    Product B 600 | 300. 150

    I would like to add month on month column as follows:
    Month0 | Months1. Month2. Month on Month (%)
    Produces a 500 | 100. 200 | + 100.00%
    Product B 600 | 300. 150. -50.00%

    I tried to add a calculated item, but it failed because I couldn't find a way to not show the column calculated in percent with 2 decimal places. In addition, I would ideally prefer to have an automatic update but as far as I understand it can be done in the automatically calculated item

    I also tried to add a new column to the column area and to filter the results for the last month, then for the previous month and then based on that to calculate the necessary ratio but unfortunately it does not work.

    Thank you in advance your advice

    Hello

    The best way to solve this problem is by using the function Ago. With this, you can create a logical column for the previous month. Then you will have 2 columns available with which you can do your calculations.

    If you want to do this with a calculated item (don't know if formatting will work for you), but you can do the more general calculation using $1 for the $2 for the 2 column and 1 column in your calculation. If ($x) columns will change with the columns in your report.

    Concerning

  • I would like to remove the automatic renewal for three months of Apple's music essay. How do I do that?

    I did the free trial of three months 'Apple music' a week ago. I don't want now, and I don't want that it is automatically renewed at the end of three months. How to handle this in my account? It doesn't seem to be a zone of disengagement.

    Click here, follow the instructions and wait until it expires.

    (139634)

Maybe you are looking for