Find the previous quarter
HelloI'm looking for a function that will help me find the previous quarter, then the format base quarter is YYYY | » Q'|| Q.
For example, when quater_base = 2011Q 1, I need the function returns quarter_previous = 2010Q 4.
I think I need to convert YYYY | » Q'|| Q on a date and then subtract from 91 days or use add months, but I need help conversion YYYY | » Q'|| Q for a date.
Thank you very much in advance for your help.
TERI
Hi, Teri,
Welcome to the forum!
user13426561 wrote:
Hello
I'm looking for a function that will help me find the previous quarter, then the format base quarter is YYYY | » Q'|| Q.
For example, when quater_base = 2011Q 1, I need the function returns quarter_previous = 2010Q 4.I think I need to convert YYYY | » Q'|| Q on a date and then subtract 91 days or use add months,.
Q1 is normally 90 days long. If you subtract 91 days March 1, you return of the last two quarters.
Q2 is always long for 92 days. If you subtract 91 days from May 31, you have not changed shifts.
Better use ADD_MONTHS.
but I need help conversion YYYY | » Q'|| Q for a date.
If s is a string of 6 characters such as '2011 Q 1' (i.e. Q1 2011), then
ADD_MONTHS ( TRUNC ( TO_DATE ( SUBSTR (s, 1, 4)
, 'YYYY'
)
, 'YEAR'
)
, 3 * ( TO_NUMBER (SUBSTR (s, 6, 1))
- 1
)
)
is the start DATE of this quarter.
Subtract 3 months ago, and convert it to a string such as "2010 Q 4":
TO_CHAR ( ADD_MONTHS ( TRUNC ( TO_DATE ( SUBSTR (s, 1, 4)
, 'YYYY'
)
, 'YEAR'
)
, 3 * ( TO_NUMBER (SUBSTR (s, 6, 1))
- 2 -- NOTE: subtracting 2, to get previous quarter
)
)
, 'YYYY"Q"Q'
)
These strings come Is it possible that you could change the strings to have a month ('01', '04', '07' or 10') instead of the district, or to include both? This work would be much simpler!
It's a shame that you can't use 'Q' in TO_DATE.
You might consider a user-defined function to perform the conversion above. It will make your code much cleaner, but it will be slower.
Thank you very much in advance for your help.
TERI
Published by: Frank Kulash, January 4, 2011 18:30
Corrected the two expressions
Tags: Database
Similar Questions
-
last date of the previous quarter
Hello
How can I find the last date of the previous quarter, based on the date of today (the fiscal year from April 1)
the neighborhoods are April 1 to June 30, July 1 to Sept. 30, 1 Oct to 31 Dec and 1 January to 31 MarchLast date of the quarter will be independent of how to define your fiscal year.
select trunc(sysdate,'Q') - 1 last_date from dual;
-
bougth a second hand iPhone 6 how find the previous owner using the serial number?
I bought a second hand iPhone 6 and he holds a lock to iCloud how to find the previous of this iPhone owner so that I can email him?
I don't have a serial number of the phone how to use it so that I can follow the former owner?
Unfortunately, you can not. Take it to where you bought it for a refund.
See you soon
Pete
-
Is there a way to get the first Pro CS6 with still now I can't find the previous, offered versions with the subscription of the CC 2015? What is recommended for creating DVDs with interactive menus?
Instructions again, cloud or version https://forums.adobe.com/thread/1992717 serial number
-a of notes on different versions of cloud and step by step on these differences
-contains information about the separate library download which is necessary
-CS6 is the last reminder, see here #8 why http://forums.adobe.com/thread/1337952?tstart=0Still and 10 Windows https://forums.adobe.com/thread/2015461 use the compatibility mode of Windows 8
problem/solution to install Encore CS6 https://forums.adobe.com/thread/1934087 -
Query to find the previous activity in STM
I have a data base to reflect a State of Transition (STM) Machine. It contains 3 tables: activity, node, and Transition.
Tables of knots and Transition are the configuration of the STM. They define the different possible States and the possible transitions between States.
The way that I take through the STM is recorded in the activity Table. A record is created for each visited node.
I need a query that uses the id of my current activity to find my previous activity, i.e. the activity that precedes me directly. The following rules apply:
-My Id is meaningless
-It should work for different configurations of the transition and the node tables, but:
-The starting node is always the node "A".
-There is no recursive transition, for example ('B', 'B');
-There is no circular transitions, for example ('B', 'C') and ('C', 'B')
-Transition and node tables will never change between the creation of the first activity and the execution of the query.
-The path reflected in the activity table is always a valid path.
-My current activity is always the last activity.
For all data below, find the previous activity of activity with id = 4. The correct answer is "C".
Desired output:DROP TABLE Transition; DROP TABLE Activity; DROP TABLE Node; CREATE TABLE Node ( Id VARCHAR2(1) PRIMARY KEY ); CREATE TABLE Activity ( Id Number(8,0) PRIMARY KEY, Node_Id VARCHAR2(1) ); CREATE TABLE Transition ( FromNode_Id VARCHAR2(1), ToNode_Id VARCHAR2(1) ); ALTER TABLE Activity ADD FOREIGN KEY (Node_Id) REFERENCES Node(Id); ALTER TABLE Transition ADD FOREIGN KEY (FromNode_Id) REFERENCES Node(Id); ALTER TABLE Transition ADD FOREIGN KEY (ToNode_Id) REFERENCES Node(Id); INSERT INTO Node VALUES ('A'); INSERT INTO Node VALUES ('B'); INSERT INTO Node VALUES ('C'); INSERT INTO Node VALUES ('D'); INSERT INTO Transition VALUES ('A','B'); INSERT INTO Transition VALUES ('B','C'); INSERT INTO Transition VALUES ('B','D'); INSERT INTO Transition VALUES ('C','D'); INSERT INTO Activity VALUES (1,'A'); INSERT INTO Activity VALUES (2,'B'); INSERT INTO Activity VALUES (3,'C'); INSERT INTO Activity VALUES (4,'D');
ID - C
Hello
Assuming that all Activity_id tells us nothing on the way, but all lines of activity together to form a single path, we can get results this way:
WITH all_paths AS ( SELECT 'A' || SYS_CONNECT_BY_PATH (a.Node_id, '/') || '/' AS node_id_path FROM Transition t JOIN Activity a ON a.Node_Id = t.ToNode_Id WHERE LEVEL = ( SELECT COUNT (*) FROM activity ) - 1 START WITH t.FromNode_Id = 'A' CONNECT BY t.FromNode_Id = PRIOR t.ToNode_Id ) SELECT REGEXP_SUBSTR ( node_id_path , '([^/]+)/' || ( SELECT Node_Id FROM activity WHERE Id = 4 -- target_id ) || '/' , 1 , 1 , NULL , 1 ) AS prev_id FROM all_paths ;
This means, there is some character (I used "/" above) that we know never appears in Activity.Node_Id.
Since there are no loops in Transition, it cannot be more than 1 way that involves all activity lines. If there are N lines in operation, this full path will be one that extends to LEVEL = N - 1. (It is not N, N - 1, because the join between the activity and the Transition will always leave 1 line in activity with Node_Id = 'A'). As soon as we have the full path (which is node_id_path in 1 row, produced by all_paths), we just need to guess what was the Node_Id, which corresponds to the id of the target (4 in this example) and find the previous of the delimited node_id_path node_id.
-
find the previous owner info (icloud)
Hi, how can I find the name and surname of the previous owner of my second hand iphone?
I have the apple ID, but find my iphone is on and I do not know password!
Thank you
You can't get from Apple or anyone here. You must contact the former owner, either through the person, you bought the phone you can not. Confidentiality issues prohibit Apple or the cellular carrier to release any of this information. If the person you bought isn't the former owner, then there is the possibility that the unit you have purchased has been stolen.
-
Where can I find the previous version of the BIOS to 2.54?
I accidentally updated the BIOS for my Lenovo E430. I want to go back to the BIOS, so I need the previous version. No one knows the number of the previous version and where I can find it on the Lenovo Web site?
Nice day.
Please take a look at the support site for your machines:
If you select the CD or bootable Windows Update link and scroll to the bottom of the resulting page, you'll see a grid of earlier versions, as well as their documentation files.
As with any update BIOS, please read the documentation carefully.
I hope this helps a little.
Kind regards.
-
Windows 7 Image Backup - where can I find the previous image after new backup?
My previous hard drive died, and I replaced it.
Good news: I did a backup of the system before the death of completed HDD. The image is under "WindowsImageBackup" folder on my external drive.
Then I replaced the HARD drive, picked up at the factory reset.
Before restoring the image backup, I took a step extra stupid: I thought that I should save its current state before as I have restore the previous state in case any thing wrong, so I started to sign--> system and security--> backup and restore--> backup now
Bad news: the new backup image sub-folder of "WindowsImageBackup" even erased my previous image! They have different timestamps, so different names, but the previous image has disappeared after a new creation. In fact, I killed the new backup process immediately after that I was disappearing from the previous image. He has not finished, but I can't find my previous image!
BTW, there is a lot of space on my drive. It is only 20% used!
Are there ways I can retrieve my previous image?
BTW, I use Windows 7 Home Premium. By default, all parameters are as I do factory reset.
Suggestions and help is very appreciated!
Hello
With the publication of the description, I understand that you have accidentally deleted the system image backup file. I've certainly you will help answer your query.
I wish to inform you that there is no way to get the previous system back image - which has already been replaced however, you can try a few steps to get the old image to the top, although there is no guarantee that it will work but still, you can try and see if it helps.
First of all, I suggest you to rename the WindowsImageBackup to WindowsImageBackup. Old then follow the screenshot and select the option highlighted in yellow color select another backup to restore files of.
Hope that this help, please write us back for any further assistance on this point, we will be happy to help you further.
-
The ATI driver installation cannot find the previous installation?
Hello
Yestreday, I wanted to update my current graphics driver AMD high definition and so downloaded the latest version. Before installation, the installation wizard stated that no previous directory was found and would create a new. That didn't make much sense to me, as I already had the previous version of the driver on my laptop. After a bit of research, I realized that the previous version was installed in the program (x 86), and the new system would be installed in Program Files instead
My question is; I still want to update the driver and how do I go about this? Must delete the existing one and install the new drivers?
My laptop model is dv7 - 4198ca with ATI Radeon HD 5470 Switchable Graphics.
Thanks in advance.
I have a laptop different but the same 5470 video card. Update all video pilots made me a lot of problems, I had to restore a former win7 restore point to get the Panel to catalyst and switchable graphics to work again.
During the update, I was warned with the same message as you (no previous directory).
I suggest, if you dare, to update the drivers ONLY (for version 1.771 I guess) choose updated manual and then uncheck the other characteristics (catalyst, frame MS C++, etc). I also suggest you to create a manual restore point before starting.
-
Satellite L40 - where can I find the previous BIOS?
Where find/download BIOS previous/all for L40 PSL48E files?
Hello
On the Toshiba site you can download the BIOS for Satellite L40 but it s only the most recent version.
I m wondering that you are looking for an older version of BIOS because normally the fix newest version bugs of old versions.
BIOS downgrade is possible for ASP s. Maybe you should contact them and ask. Maybe they can send you by Mail?Good bye
-
How to complete the data for months current quarter of the last month of the previous quarter
- Here is the create table and insert the statement how my data is asCREATE TABLE SAMPLEDATA (Snapshot_M DATE, Date_Ky DATE, F_Quantities INTEGER)INSERT INTO VALUES SAMPLEDATA (SEPTEMBER 1, 2014 ", 1 SEPTEMBER 2014", 14)INSERT INTO VALUES SAMPLEDATA (OCTOBER 1, 2014 ", 1 OCTOBER 2014", 13)INSERT INTO VALUES SAMPLEDATA (1 NOVEMBER 2014", 1 NOVEMBER 2013', 12)INSERT INTO VALUES SAMPLEDATA (DECEMBER 1, 2014", 1 DECEMBER 2013', 11)INSERT INTO VALUES SAMPLEDATA (JANUARY 1, 2014 ", 1 JANUARY 2014", 10)INSERT INTO VALUES SAMPLEDATA (FEBRUARY 1, 2014 ", 1 FEBRUARY 2014", 90)INSERT INTO VALUES SAMPLEDATA (MARCH 1, 2014 ", 1 MARCH 2014", 20)INSERT INTO VALUES SAMPLEDATA (APRIL 1, 2014 ", 1 APRIL 2014", 23)INSERT INTO VALUES SAMPLEDATA (MAY 1, 2014", 1 MAY 2014', 30)INSERT INTO VALUES SAMPLEDATA (JUNE 1, 2014 ", 1 JUNE 2014", 70)INSERT INTO VALUES SAMPLEDATA (JULY 1, 2014 ", 1 JULY 2014", 20)Desired results set:Snapshot_M Date_Ky F_Quantities10 1/1/2014-2/1/201410 1/1/2014-3/1/201401/01/2014 41 10/20144/1/2014 5/1/2014 234/1/2014 6/1/2014 234/1/2014 7/1/2014 23My requirement is to load the data in the cube.So to summarize, data that are loaded onto the month last only a quarter Q1 tax (Jan) should server as a data for the quarter Q2 next month (February, March, April), the data loaded on the last month of Q2 (Apr) will be server as forecast data for Q3 months and so on.Thank you in advance.
with
SAMPLEDATA as
(select to_date('09/1/2014','mm/dd/yyyy') snapshot_m, to_date('09/01/2014','mm/dd/yyyy') date_ky, 14 f_quantities of all the double union)
Select to_date (October 1, 2014 "," mm/dd/yyyy ""), to_date (1 October 2014 "," mm/dd/yyyy"), 13 union double all the
Select to_date (November 1, 2013 "," mm/dd/yyyy ""), to_date (1 November 2013 "," mm/dd/yyyy"), 12 union double all the
Select to_date (December 1, 2013 "," mm/dd/yyyy ""), to_date (1 December 2013 "," mm/dd/yyyy"), 11 union double all the
Select to_date (January 1, 2014 "," mm/dd/yyyy ""), to_date (1 January 2014 "," mm/dd/yyyy"), 10 of all the double union
Select to_date (February 1, 2014 "," mm/dd/yyyy ""), to_date (1st February 2014 "," mm/dd/yyyy"), 90 union double all the
Select to_date (March 1, 2014 "," mm/dd/yyyy ""), to_date (1 March 2014 "," mm/dd/yyyy"), 20 union double all the
Select to_date (April 1, 2014 "," mm/dd/yyyy ""), to_date (1 April 2014 "," mm/dd/yyyy"), 23 union double all the
Select to_date (May 1, 2014 "," mm/dd/yyyy ""), to_date (1 may 2014 "," mm/dd/yyyy"), 30 union double all the
Select to_date (June 1, 2014 "," mm/dd/yyyy ""), to_date (1 June 2014 "," mm/dd/yyyy"), 70 union double all the
Select to_date (July 1, 2014 "," mm/dd/yyyy ""), to_date (1 July 2014 "," mm/dd/yyyy"), 20 union double all the
Select to_date (August 1, 2014 "," mm/dd/yyyy ""), to_date (1 August 2014 "," mm/dd/yyyy"), 22 of the double
)
Select snapshot_m, date_ky, last_value (f_quantities) ignore nulls on f_quantities (order by date_ky)
of (trunc (add_months (snapshot_m-1), 'q') select snapshot_m, date_ky,)
-case when trunc (add_months (snapshot_m-1), 'q')! = lag (trunc (add_months(snapshot_m,-1), 'q')) (date_ky order)
then lag (f_quantities) (date_ky order)
end f_quantities
of sampledata
where date_ky > = date ' 2014-01-01'
)
where snapshot_m > = date ' 2014-01-01'
order of date_ky
SNAPSHOT_M DATE_KY F_QUANTITIES 01/01/2014 01/02/2014 10 01/01/2014 01/03/2014 10 01/01/2014 01/04/2014 10 01/04/2014 01/05/2014 23 01/04/2014 01/06/2014 23 01/04/2014 01/07/2014 23 01/07/2014 01/08/2014 20 01/07/2014 01/09/2014 20 01/07/2014 01/10/2014 20 Concerning
Etbin
-
My MAC crashed and I had fixed. Problem is the guy who fixed it, he wiped away. Can I re-download my previous version of Photoshop Elements (11)? The next problem is, I have to do from the internet bc my HDD is screwed. I bought an external disk for her drive, but that won't work either. Any help is appreciated. Thank you.
Available downloadable Setup files:
- Suites and programs: CC 2015 | CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4, CS4 Web Standard | CS3
- Acrobat: DC, XI, X | Suite X | 9,8 | 9 standard | 8 standard
- Captivate: 8 | 7 | 6 | 5.5, 5 | 1
- Cold Fusion: 11: 10 | 9.0.2 version 9.0.0, 9.0.1, 8.0.1, 8.0.0, 7.0, 6.1, 6.0, 5.0, 4.0
- Contribute: CS5 | CS4, CS3 | 3,2
- FrameMaker: 12, 11, 10, 9, 8, 7.2
- Lightroom: 6| 5.7.1| 5 | 4 | 3
- Photoshop Elements: 14,13,12,11,10 | 9,8,7 win | 8 mac | 7 mac
- Premiere Elements: 14,13,12,11,10| 9, 8, 7 win | 8 mac | 7 mac
Download and installation help links Adobe
Help download and installation to Prodesigntools links can be found on the most linked pages. They are essential; especially steps 1, 2 and 3. If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".
-
find the previous value of the oracle table
Hello
I have a stat table who got the news as login_date, user_id, etc..
For a specific user, I have a requirement based on the no the difference in days between the date of opening of the current session and the date of last.
For example, Tom connected on June 4, 2013. His previous connection was May 31. No_of_days_difference is 5 days.
How to programmatically for each user inside a block of sub pl - sql.
Appreciate your help
Thank you
KPHello
Here's one way:
WITH got_analytics AS ( SELECT user_id, login_date , LAG (login_date) OVER ( PARTITION BY user_id ORDER BY login_date ) AS prev_login_date , ROW_NUMBER () OVER ( PARTITION BY user_id ORDER BY login_date DESC ) AS r_num FROM stat -- WHERE ... -- If you need any filtering, put it here ) SELECT user_id, login_date , prev_login_date , login_date - prev_login_date AS days_difference FROM got_analytics WHERE r_num = 1 ;
As you can see, you needn't PL/SQL to do this, but if you need to use the PL/SQL for another reason, you can do the same thing in PL/SQL.
I hope that answers your question.
Otherwise, your zip code, a little sample of data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Point where the above statement is erroneous results, and explain, using specific examples, how you get the right result of data provided in these places.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002} -
How to find the previous mouse clicked the check box
Hello
In my form with detail and header boclk
For example: in a canvas
My requirement is now knowledge/capture when the user clicks the check boxes.Header ----------- item1 item2 item3 item4 item5 item6 Detail --------- item7 item8 item9 checkbox1 item7 item8 item9 checkbox1 item7 item8 item9 checkbox1 item7 item8 item9 checkbox1 item7 item8 item9 checkbox1 item7 item8 item9 checkbox1 item7 item8 item9 checkbox1
If he clicks on the 1st record or record of 5th or 3rd I wants to get these values and that it must handle
further...
Thank you.Hello
When you click anywhere in a recording, it becomes the current record, and you can get/set values using domain names.
When the user clicks a control checkbox, its trigger raises the when-box-change and you know its value (if it is selected or deselected).François
-
For the previous fiscal quarter date settings?
Hello people,
I have this requirement to choose the dates for the previous quarter. a fiscal quarter is usually January 2011 - March 2011. But in my case, the exercise should be December 2010 to February 2011 and if I check in June 2011 it must return to Mar 2011 until May 2011 and so on. So, how can I optimize to be able to select these dates i.e. 01/12/2010 until 28/02/2011 in where clause for the current date?
create table test_A (id int, col varchar(50),change_date date); insert into test_A values(1, 'A',to_date('20101201 000000', 'YYYYMMDD HH24MISS')); insert into test_A values(2, 'A1',to_date('20110122 000000', 'YYYYMMDD HH24MISS')); insert into test_A values(3, 'A1',to_date('20110202 000000', 'YYYYMMDD HH24MISS')); insert into test_A values(5, 'A1',to_date('20110306 000000', 'YYYYMMDD HH24MISS')); insert into test_A values(6, 'A1',to_date('20110305 000000', 'YYYYMMDD HH24MISS')); insert into test_A values(7, 'A1',to_date('20110307 000000', 'YYYYMMDD HH24MISS')); select * from test_A 1 1 A 12/1/2010 2 2 A1 1/22/2011 3 3 A1 2/2/2011 4 5 A1 3/6/2011 5 6 A1 3/5/2011 6 7 A1 3/7/2011 I only want to see the following 1 1 A 12/1/2010 2 2 A1 1/22/2011 3 3 A1 2/2/2011
select * from test_A where change_date >= add_months(trunc(sysdate,'Q'),-1) and change_date < add_months(trunc(sysdate,'Q'),2) / ID COL CHANGE_DATE ---------- -------------------------------------------------- --------------- 1 A 20101201 000000 2 A1 20110122 000000 3 A1 20110202 000000 3 rows selected. SQL>
SY.
Maybe you are looking for
-
I try to print of the Samsung Galaxy Tab 10.1 10 HP Officejet 6700 Premium
-
After installing these updates, you get a message that can not search the updates with an error code: 80004002 We run Advanced System Care, CCleaner and anti-virus from Norton (latest version). Help?
-
What is the color code of the network cable?
-
Wie kann ich can reach, das beim vergrossern mit dem das Bild nicht hinter Paletten rutscht die Zoom-tool?
-
My Premiere Pro is in trial mode with an active participation of creative cloud
Please respond with an answer as soon as possible.