last date of the previous quarter
HelloHow 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 March
Last date of the quarter will be independent of how to define your fiscal year.
select trunc(sysdate,'Q') - 1 last_date from dual;
Tags: Database
Similar Questions
-
Extract the first and the last Date of the previous month
This seems to be a delicate but again it is perhaps easy for some of you people.
Here is how I find the previous month
Any ideas on how to get the first and last date of the previous month?
Thanks in advance.Hello!
SQL> SQL> select last_day(add_months(sysdate,-1)) from dual; LAST_DAY -------- 28.02.10 SQL> select trunc(add_months(sysdate,-1),'MM') from dual TRUNC(AD -------- 01.02.10 SQL>
T
-
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
-
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 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.
TERIHi, 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.
TERIPublished by: Frank Kulash, January 4, 2011 18:30
Corrected the two expressions -
How to get sales last day of the previous month
HELO guys
I have a question how do I get sales date last day of the previous month where my fact table is level. in fact I tried using Ago but it seems not working. for example, if I chose December 29, 2014 so if I used the function there are then the result will display data on November 29, 2014 (not the last day of November 2014).
Please guys if you have any solution and I really advise thanks to you.
Not exactly under what circumstances specific as you try to reach this goal, but suppose you have a few guest dashboard where you select a day and you have a report with a measure where you want to show the sales of the last day of the previous month based on the selected date in the dash prompt.
If you change the formula of this measure to something like:
FILTER (with the HELP of 'Sales' (DATE = TIMESTAMPADD (SQL_TSI_DAY-1, TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH(@{PV_DATE_SELECTED}) * (-1) + 1, @{PV_DATE_SELECTED}))))
-
retrieve the last date of the month
Hello
I give myself a date. I want to find the last date of the month containing the given date.
Is there any built-in why?
Thanks in advance.
DateTimeUtilities.getNumberOfDaysInMonth (cal.get (Calendar.MONTH), cal.get (Calendar.YEAR));
-
To get the last date of the year
Can someone tell me how to get the date of the year from the first date of last year:
My query below gives the last date of the month
SELECT LAST_DAY (ADD_MONTHS (TO_DATE (JANUARY 1, 2012 "," DD/MM/YYYY '), 12-))
TO_NUMBER (to_char (sysdate, 'mm'))) OF the DOUBLE
Thnx in advanceSELECT LAST_DAY (ADD_MONTHS (TO_DATE ('01/01/2012', 'DD/MM/YYYY'), 11)) FROM DUAL
-
Get the date of the previous year
Hi all
How can I recover date from the previous year, based on today's date, if I have a data type 'date '.Marwim wrote:
Hello BluShadow,You should know better ;-)
select date '2004-02-29' - interval '1' year from dual; ORA-01839: date not valid for month specified
Well, today he works.
Concerning
MarcusEdited by: Marwim the 13.10.2011 17:06
Ah, good point. Really, it's oracle who should know better. It should do the same thing as:
select add_months(date '2004-02-29',-12) from dual;
-
Function to move all the dates for the previous Monday
Here's what I have:
create or replace
FUNCTION ToPreviousMonday
(DATE_FIELD IN date)
Date of RETURN
AS
BEGIN
IF TO_DATE (DATE_FIELD, 'DAY') = 'SUN' THEN (DATE_FIELD)-6;
Of ANOTHER trunc (DATE_FIELD, 'd.') + 1;
END IF;
END ToPreviousMonday;
Don't compile.
Basically, what I want to accomplish is in a SELECT statement, say something like (SELECT ToPreviousMonday (MyDateField) FROM MaTable) and cause the data back as the date of the previous Monday. NLS_TERRITORY is and will be for all the sessions going to Sunday as the day of the week 1.
Pointers?Use:
TRUNC (DATE_FIELD, 'IW')
IW means ISO week which starts always on Monday regardless of NLS.
SY.
-
Get the data from the current quarter
Hello
I was wondering how I would go about getting data from a table that is in the current fiscal quarter?
It's the simple query to get all the data:
$q_calls_sql = "SELECT * FROM renewal_contact WHERE userid ='". "." ' $user_id. "'";
$q_calls_query = $con-> query ($q_calls_sql);
$q_calls_numrow = $q_calls_query-> num_rows;
Here's what I currently show the quarterly data, but only shows do not all data:
$q_calls_sql = "SELECT."
OF renewal_contact
WHERE the timestamp > = GETDATE(), DATEADD (qq, 1, getdate ()) & & timestamp < GETDATE(), DATEADD (qq, 2, getdate ()) ';
$q_calls_query = $con-> query ($q_calls_sql);
$q_calls_numrow = $q_calls_query-> num_rows;
All I have to do is show the num_rows of the above query.
MySQL QUARTER() function deals with calendar quarters rather than the fiscal quarters. In the United States, first by the federal Government's fiscal quarter begins October 1, dealing with MySQL as in the fourth quarter. The first fiscal quarter in California begins on 1 July, that MySQL considers (rightly) as of the third quarter.
A way to get the quarter is to use a custom like this function:
function getFiscalQuarter() { $month = date('n'); $year = date('Y'); switch ($month) { case 1: case 2: case 3: return ["$year-01-01", "$year-03-31"]; case 4: case 5: case 6: return ["$year-04-01", "$year-06-30"]; case 7: case 8: case 9: return ["$year-07-01", "$year-09-30"]; default: return ["$year-10-01", "$year-12-31"]; } } $quarter = getFiscalQuarter(); $sql = 'SELECT * FROM renewal_contact WHERE `timestamp` BETWEEN "' . $quarter[0] . '" AND "' . $quarter[1] . '"';
-
date of breach varies at continuous intervals and ending date of the previous row
Hello
can someone give me an idea for situation below
I have a table with records
I want to merge the range date lines that overlap, break at intervals and set the indicator (A_IND, B_IND, Q_IND) accordingly. (IE, if a record in the source has a value for the 'cd' = 'B' column in a given date range, then the output should display 'Y' for the B_IND column for the date ranges in the source folder.)CREATE TABLE test1 ( key VARCHAR2(11 BYTE) NOT NULL ENABLE, cd VARCHAR2(10 BYTE) NOT NULL ENABLE, start_dt DATE NOT NULL ENABLE, end_dt date, CONSTRAINT x1 PRIMARY KEY (key, cd, start_dt)); Insert into test1 (key,cd,start_dt,end_dt) values ('1234','A',to_date('01-MAR-78 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('31-DEC-99 00:00:00','DD-MON-RR hh24:mi:ss')); Insert into test1 (key,cd,start_dt,end_dt) values ('1234','B',to_date('01-MAR-78 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('31-DEC-99 00:00:00','DD-MON-RR hh24:mi:ss')); Insert into test1 (key,cd,start_dt,end_dt) values ('1234','Q',to_date('01-JAN-89 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('31-JAN-97 00:00:00','DD-MON-RR hh24:mi:ss')); Insert into test1 (key,cd,start_dt,end_dt) values ('1234','B',to_date('01-FEB-97 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('30-APR-97 00:00:00','DD-MON-RR hh24:mi:ss')); insert into test1(key,cd,start_dt,end_dt) values ('1234','Q',to_date('01-FEB-97 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('30-APR-97 00:00:00','DD-MON-RR hh24:mi:ss')); Insert into test1 (key,cd,start_dt,end_dt) values ('1234','B',to_date('01-MAY-97 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('31-MAR-99 00:00:00','DD-MON-RR hh24:mi:ss')); commit; key cd start_dt END_DT 1234 B 01-MAR-78 00:00:00 31-DEC-99 00:00:00 1234 A 01-MAR-78 00:00:00 31-DEC-99 00:00:00 1234 Q 01-JAN-89 00:00:00 31-JAN-97 00:00:00 1234 Q 01-FEB-97 00:00:00 30-APR-97 00:00:00 1234 B 01-FEB-97 00:00:00 30-APR-97 00:00:00 1234 B 01-MAY-97 00:00:00 31-MAR-99 00:00:00
I want also to the date of the end of each record to be 1 day less than the start_dt of the next record, as shown below.
and the output should bekey start_dt END_DT A_IND B_IND Q_IND 1234 01-MAR-78 00:00:00 31-DEC-88 00:00:00 Y Y N 1234 01-JAN-89 00:00:00 30-JAN-97 00:00:00 Y Y Y 1234 31-JAN-97 00:00:00 31-JAN-97 00:00:00 Y Y N 1234 01-FEB-97 00:00:00 29-APR-97 00:00:00 Y Y Y 1234 30-APR-97 00:00:00 30-APR-97 00:00:00 Y Y N 1234 01-MAY-97 00:00:00 30-MAR-99 00:00:00 Y Y N 1234 31-MAR-99 00:00:00 31-DEC-99 00:00:00 Y Y N
Hello
user12997203 wrote:
Hello
can someone give me an idea for situation belowI have a table with records
CREATE TABLE test1 ...
Thanks for the display of the data of the sample; It is very useful.
I want to merge the range date lines that overlap, break at intervals and set the indicator (A_IND, B_IND, Q_IND) accordingly. (IE, if a record in the source has a value for the 'cd' = 'B' column in a given date range, then the output should display 'Y' for the B_IND column for the date ranges in the source folder.)
Do not assume that everyone who wants to help you is familiar with your application and your needs. Explain what key role plays in this problem. See {message identifier: = 10865697}.
Here's one way:WITH change_points AS ( SELECT key , start_dt AS dt FROM test1 UNION SELECT key , end_dt AS dt FROM test1 ) , ranges AS ( SELECT key , dt AS start_dt , LEAD (dt) OVER ( PARTITION BY key ORDER BY dt ) AS next_dt FROM change_points ) SELECT r.key , r.start_dt , r.next_dt - CASE WHEN r.next_dt = MAX (r.next_dt) OVER () THEN 0 ELSE 1 END AS end_dt , MAX (CASE WHEN t.cd = 'A' THEN 'Y' ELSE 'N' END) AS a_ind , MAX (CASE WHEN t.cd = 'B' THEN 'Y' ELSE 'N' END) AS b_ind , MAX (CASE WHEN t.cd = 'Q' THEN 'Y' ELSE 'N' END) AS q_ind FROM ranges r JOIN test1 t ON t.key = r.key AND t.start_dt < r.next_dt AND t.end_dt > r.start_dt GROUP BY r.key , r.start_dt , r.next_dt ORDER BY r.start_dt ;
Note that this depends on the values that you want in the columns a_ind, b_ind and q_ind. For example, if you were doing this for users of German language, you might want to show 'J' and 'n' instead of 'Y' and 'n'. In this case, you would use MIN instead of MAX, to get the dominant value.
-
Calculation of current date or the previous months
Script gurus of wishes!
I would like to ask help on calculating Date.
Here's my current scenario:
The user enters a date mm/dd/yyyy ("DateField")
Power here ask the 'DateField' to calculate these items:
Less "DateField" 12 months = ("12MonthsAgoDateField") / mm/yyyy
'DateField' 18 months = ("18MonthsAgoDateField") / mm/yyyy
'DateField' less than 36 months = ("36MonthsAgoDateField") / mm/yyyy
and so on...
I read some posts Date of calculation, but could barely find anything that fit this scenario.
Freely, I confess that my ability to script is very minor.
I would appreciate help in this script.
Thank you!
If you really want to go into the details (or not the time to do)
Here is the simple solution to your problem.
I wrote a small function (a few lines)
Put this in the document level javascript
Function level javascript document-
function getPastDate (textFieldName, month) {}
var util.printd = cDate ("dd/mm/yyyy", new Date (this.getField ("textFieldName") .value));
sDate var = util.scand ("mm/dd/yyyy", cDate);
If (sDate == null) {}
App.Alert ("Please enter a valid date in the form \"mm/dd/yyyy\". »)
} else {}
update var = new Date (sDate.getFullYear (), (sDate.getMonth () + months), sDate.getDate ());
Return util.printd("mm/yyyy",pDate);
}
}
Now suppose that we have a text box name "Text1" including the date in the format "mm/dd/yyyy".
1st parameter is for the name text box (seen the date that you want to process)
2nd parameter is the number of months (to subtract pass a negative value)
If you want to get the result in another area of text "Text2" write the following code in the event to calculate Text2
Event.Value = getPastDate ("Text1",-12);
This removes 12 month value "Text1".
Hope this will help
-
OCD books display the last topic in the previous book when you click
I found a weird behavior when looking at the release published on HR Server 8 from a client RH8 and using a merged help file configuration (implementing merged maybe project although not relevant). By clicking on any book TOC displayed in the topic pane the last topic in the book of immediatey above him. In the example below, the table of contents is on the 'Basics' book and the displayed topic is "Tab management" which lies immediately above the book. Any book is clicked, the same behavior follows.
This problem is limited to when help is displayed via the HR eithere server by clicking on the button 'View Project' with the Web administrator or displayed through the application. Bizzarely, it does not occur if you manually open the start page in a web browser from the HR server. Or the problem itself using the WebHelp output manifest.
Someone has seen this. I tried to report it as a bug but thought that I have would float it out there first.
Hi - I believe that the problem has already been postponed.
See http://forums.adobe.com/click.jspa?searchID=1351909&objectType=2&objectID=2026022
-
Get the end date as effective date of the previous record
< p >
Hello.
I have a table as follows:
employee_id
position_number
effective_date
The primary key is (employe_id, position_number)
An employee of a company may hold several positions during their tenure, but support one position at a time.
for example,.
employee 1, position 10 from 01/01/07
1: 17 employee's position, effective 03/02/08
employee 1, 5 post, effective 06/01/08
I need return the date of end of previous, if possible:
1 position 5 of 01/06/08 to present
1 post 17 02/03/08 to 05/31/08
employee position10 1 outfit since 01/01/07 to the 02/02/08
I have no idea how to proceed. Can someone help, please?
< /p >use "lag (effective_date) over (partition by employee_id order by effective_date)" in your query
-
I hope you understand what I mean, because English is not my language, but Dutch.
Example: 17/11/2014
16-11-2014 15-11-2014 so I recieved my e mails and now
15/11/2014
16/11/2014
17/11/2014and I want that the date of most recent entry up
I hope that there is someone to help me.
Thank you.Heinja
Click the header to sort the column.
Maybe you are looking for
-
two device to listen to music online at the same time
I have only one subscription, but I can't listen to music online of my two devices at the same time... If I buy the family pass... could do? Thank you, Diego
-
Question for the Experts of Teststand
Hello! I need some advice on what the best method to perform the following operations in Teststand. I have a PLC driven station and who communicates to the control device in the IP Ethernet Toolbox. My question is: what do you suggest the best way to
-
Verification of XP Service Pack
Y at - it a new version of spcheck.ini that includes the files for SP3?
-
Windows Update does not work with IE 8
When I try to use windows update, I am directed to the error page tells me that in order to use windows update, I need to upgrade to a more recent than IE 5 web browser; Well, I use IE 8.
-
Why don't my NOTHING full of Vista SP2?
OK - Here's the dope:An acquaintance brought me a Dell laptop which was... uh, seriously 'degraded.(in fact she brought me TWO portable identical problems similar-more on that later)Details-(on two laptops) Dell Inspiron 1525, with 3 GB of RAM and a