Complete Weeks of current Quarter ..
Hello,
we have a time table (exp.: D_TIME) listing every day between 1.1.2006 to 1.1.2017
and i am triying to filter with following criteria ..
Complete Weeks of the current Quarter (Only weeks wich are from Monday to Sonday included in the current quarter)
AND < SYSDATE
The borders of this Filter are correct but in some days teh result is empty ..
+
SELECT * D_TIME
WHERE
D_TIME.DATE_X BETWEEN NEXT_DAY(TRUNC(TRUNC(trunc(SYSDATE), 'iw'),'Q')-1,'Monday')
AND TRUNC(trunc(SYSDATE),'iw')-1
+
ANY Suggestions .. ? Thanks ..
Hi,
To find all the days between the first Monday in this quarter, and the last Sunday before today, inclusive:
SELECT *
FROM d_time
WHERE date_x BETWEEN TRUNC ( TRUNC (SYSDATE, 'Q') + 6
, 'IW'
AND TRUNC (SYSDATE, 'IW') - 1
;This assumes that d_time.date_x is always midnight (00:00:00).
When you TRUNCate a date to some longer time division (such as a quarter),that implies TRUNCating to all smaller divisons that are contained in it, so
TRUNC (d, 'IW') truncates the hours, minutes and seconds; there's no need to say
TRUNC (TRUNC (d), 'IW').
NEXT_DAY is very handy, but it depends on NLS_DATE_LANGUAGE. TRUNC (d, 'IW') works the same regardless of your NLS settings.
This may still retun 0 rows. For example, as of Sunday, October 9, 2001 there had not been a Monday-to-Sunday week that fell entirely in the current quarter. (The week starting on Monday, Octoeber 3 was not yet complete, by a fraction of a day.)
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
Similar Messages
-
How to get Current week and No of Weeks for each quarter!!
Hi,
As a part of report development I have to derive Current week and No.of Weeks in Curreny Query. Based on these information I have to calculate Phased target (Calculated KYF).
Phased target = (Target for Quarter / No of weeks in Current Quarter) X Current Week.
We have to derive Current Quarter and Current week from Customer Exit (From Invoice date, which is an entry by Users at report level).
My questions are:
1) We have to derive Two Restricted key figures (by Calweek) for derving No of weeks for Currnet Quarter and Current week in Query level. Based on this info, we have to derive Calculated kef figure for Phased target.
2) And the output is 6 (ex:- 132008) char length for Current week and we have to pick Week info only and we have to populate RKF created for Current week. How we can achieve this.
3) Regarding the No of weeks per for current quarter, we are writing Customer exit to determine Quarter and no of weeks, but how to bring this info in query level.
4) Is there any standard code available (SAP Exit) to find Current week and No of Weeks in Current quarter.
Regards,
Suresh MolliHi Venkat Molli,
Follow the below step for the doing the same:
1. Create a customer exit variable on calweek.
2. Restrict the created variable for respective info object.
3. To Populate the data write code in CMOD.
in enhancement function module: EXIT_SAPLRRS0_001 -> in Include ZXRSRU01 write the below code:
WHEN '<variable name>'.
IF i_step = 1.
CLEAR l_s_range.
CALL FUNCTION 'RSVAREXIT_0P_CWEEK'
IMPORTING
e_t_range = lt_week.
READ TABLE lt_week INTO l_s_range1 INDEX 1.
v_last_week = l_s_range1-low+4(2).
v_last_week = v_last_week - 1.
l_s_range1-low+4(2) = v_last_week.
l_s_range-low = l_s_range1-low.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDIF.
4. Execute the report.
I hope you can handle you issue now.
Assign points if it is helpful.
Regards,
S P. -
How to derive Current week and Number of Weeks for present quarter.
Hi,
Currently we are developing a report on Actuals and Planned sales. We have two different data targets to hold these information.
CRM team will provide targets for BP monthly in CRM table, from where we are extracting the data into BW and report exection frequency is Daily.
Report Output format:-
1) Target1St Month in the quarter, Target2nd Month in the quarter, Target3rd Month in the quarter, Target Quarter, Month To date (Taget for Current month - Sales till today),
Let us assume we are Q1 and user executing this report on end of March Target1 = Jan, Target2 = Feb, Target 3 = March and Quarter target = Target1 + Target2 + Target 3.
We can achieve this by offset variables.
But if users are exectuing this report Apr (Q2) then Target1 = Apr target , target2 and target3 =0
Becoz we are in Q2 and first month of the quarter. If users are executing this report in May target1 should be Apr target and Target 2 = May target and Target3rd month should be Zero.
2) We have one keyfigure called as Quarter Phased Target = (Quarter target/ No of weeks in current quarter)* current week; For this we have to get No of weeks in every quarter and Curren week (when the reports get executed).
Let us assume we are executing this report on 25th jan and target for that month = 122units then Quarter phased target = [(122 + 0 (For Feb)+ 0 (For Mar) )/ 13] X4
4 is becoz we are in 4th in that quarter,
13 is becoz no of weeks in that quarter.
0 (For Feb) - Becoz we are in Jan only..
Hence please let me know how to get No of weeks in Current quarter and Current week for every quarter..
All the helpful answers will be awarded with full points.
Regards,
sureshhi,
For the first querry.
the problem is because u are using calmonth.
Instead of using cal month use fiscal period.
When u use fiscal period the data will be shown automatically for the Previous months using offsets.
u have to take taht in ur transformation and should map it to constant value depending on the fiscal periods of ur compnay?
march- apr,jan-dec etc.
for teh second querry there would be some charecteristic which might give data in weeks as well just check that and if availabe u can use it.
am not too sure abt it. -
Get the Current Quarter and Current Week from date
Hi,
I want to get the Current quarter and Current week from a given date, which function modules should i use?
I tried using function module - 'HR_99S_GET_QUARTER' for getting the quarter but it is throwing an error while loading data. Moreover it doesnt exist in BI7.
Similarly for current week.
Please help. Sample code snippets would be appreciated.
Thanks
JayaYou can use FORM time_conversion wich is the one used by standard in Update Rules:
You can select whether convert 0CALDAY to 0CALWEEK or whatever infobject formats you prefer...
perform time_conversion
using '0CALDAY'
'0CALMONTH'
p_input_date
l_fscvtval
changing RESULT
c_t_idocstate
c_subrc
c_abort.
if c_subrc <> 0 or c_abort <> 0.
exit.
endif.
form time_conversion
using i_timnm_from type rsiobjnm
i_timnm_to type rsiobjnm
i_timvl
i_fiscvarnt type t009b-periv
changing e_timvl
c_t_idocstate type rsarr_t_idocstate
c_subrc like sy-subrc
c_abort like sy-subrc. "#EC *
data: l_timvl type rsd_chavl,
l_result type rsd_chavl.
IF i_timvl CO ' 0'.
CLEAR e_timvl.
EXIT.
ENDIF.
l_timvl = i_timvl.
CALL FUNCTION 'RST_TOBJ_TO_DERIVED_TOBJ'
EXPORTING
i_timnm_from = i_timnm_from
i_timnm_to = i_timnm_to
i_timvl = l_timvl
I_FISCVARNT = i_fiscvarnt
I_BUFFER = rs_c_true
IMPORTING
E_TIMVL = l_result
EXCEPTIONS
INCOMPATIBLE_TOBJS = 1
NO_INPUT_VALUE = 2
FISCVARNT_MISSING = 3
INPUT_NOT_NUMERIC = 4
WRONG_DATE = 5
WRONG_FISCPER = 6
X_MESSAGE = 7
OTHERS = 8
e_timvl = l_result.
ENDFORM. "TIME_CONVERSION -
Balance sheet required for current quarter and previous quarter
Hi Guys,
I am using 0FIGL_C10 cube for balance sheet report,i need to create balances for current quarter and previous quarter.
user will enter the fisper, based on fisper it has to show the current quarter and previous quarter balance.
how to calculate the quarter using fisper.you can use offset with ranges.
or
just offset of -1 , -2 & -3 seperately in 3 selections and add it in one column in formula (this will give u current quarter).
similarly offset of -4, -5 , -6 will give u previous quarter result.
total of 6 selection and 2 formulas. hide all selections from display. -
How to get Current Quarter and Fiscal Quarter for a Date - Fiscal Year starts from 1st April
Hi,
I need to calculate current quarter and fiscal quarter in my Sql query.
I have a column for DateTime Datatype.
I need to find out Current Quarter Name like Q12012, Q22012, Q32012, Q42012 and Fiscal Quarter Name as well.
Now Fiacal Year starts from 1st April, and Current Quarter starts from 1st Jan.
For Current Quarter of 2012
Jan-Mar = Q12012
Apr-Jun = Q22012
Jul-Sep = Q32012
Oct-Dec = Q42012
For Fiscal Quarter of 2012 ( starts from 1st Apr, 2011 )
Apr2011-Jun2011 = Q12012
Jul2011-Sep2011 = Q22012
Oct2011-Dec2011 = Q32012
Jan2011-Mar2012 = Q42012
means if its 1st April, 2012,
its a new Fiacal Year 2013 so Fiacal Quarter Name should be Q12013
and its Current Quarter Name should be Q22012
Can you help me to calculate this in a select query for given dates?
Thanks in advance,
NiravThis should do it..
Select
FORMAT(datepart(quarter,getdate()),'Q#')+FORMAT(getdate(),'yyyy') -
Urgent ...! How to get Current Quarter of the Fiscal Year
Hi Friends,
I need to calculate current Quarter of the Fiscal Year 4 , 5 like that. SAP has Provided 3 Variable(Current Quarter of the Fiscal Year 2 like that 3 variables), my customer is looking for some more variables. Can any one help me out hhow to Calculte Current Quarter of the Fiscal Year 4. How can i see the code of the SAP EXit's. Based on that i will try to write the code.
Thanks in Advance!
Nagesh.Hi Nagesh,
the code for SAP Exits must be in Function-Pools SAPLRS_BCT* (I'm not quite sure). But this code
seems to work different than customer Exits.
See How-To-Guide
https://service.sap.com/~sapdownload/011000358700002762582003E/HowToDeriveVariableValue.pdf
for a good example of how to implement Customer-Extis.
(It's a 2.x Guide but still valid for 3.x)
Regards
Robert -
I have created a form which needs to be completed once a week for 6 weeks. On completing week 1, weeks 2 - 6 are completed at the same time with week 1 information. please help?
Hello, thanks for replying.
Yes they just copy to the next page, the fields are the same. The document is an observation to school lessons so it needs to be consistent but with different data on. -
Query to find the start and end date of current quarter
I want a query to give me the start date and end date of current quarter
I don't want to use TRUNC and ROUND as the 16th day roundoff logic is not required.
Thanks in advance.Hi ,
I'm quite sure that the year quarters are static.....
So , you can save them as records of a table , such as:
QRTY START_DAY END DAY
============================
1 1/1 30/3
2 1/4 30/6
3 1/7 30/9
4 1/10 31/12
The sysdate(day of the current quarter) must be between a start_day and appropriate end_day of the quarters, concatenated with the sysyear (year of the sysdate).
So , if the above table is called Quarters ...
then
select start_day , end_day
from quarters
where to_date(sysdate,'dd/mm/rrrr') between (to_date(trim((start_day||'/'||to_char(sysdate,'rrrr'))),'dd/mm/rrrr'))
and (to_date(trim((end_day||'/'||to_char(sysdate,'rrrr'))),'dd/mm/rrrr'));
[b]Result
START_DAY END_DAY
1/10 31/12
Regards,
Simon
Message was edited by:
sgalaxy
Message was edited by:
sgalaxy -
Need to know first day of current quarter
hi,
I want to implement a variable to dertermine the date range of "the quarter to date" of last year:
low: current date -364
high: first day of current quarter -364
so if anybody knows how to get the first day of current quarter, based on teh current date?
Thank you so much in advance,
PingHi Ping,
Just curious whether the code worked or not and if it worked how did u solve the error message ?? keep us posted.
do the foll modifications to get last qtr.
data: qtr like sy-datum.
data: lqtr like sy-datum. --- newly added
if sy-datum4(2) = '01' or sy-datum4(2) = '02' or
sy-datum+4(2) = '03'.
qtr(4) = sy-datum(4).
qtr+4(4) = '0101'.
lqtr(4) = sy-datum(4) - 1. --- newly added
lqtr+4(4) = '0101'. --- newly added
elseif sy-datum4(2) = '04' or sy-datum4(2) = '05' or sy-datum+4(2) =
'06'.
qtr(4) = sy-datum(4).
qtr+4(4) = '0401'.
lqtr(4) = sy-datum(4) - 1. --- newly added
lqtr+4(4) = '0401'. --- newly added
elseif sy-datum4(2) = '07' or sy-datum4(2) = '08' or sy-datum+4(2) =
'09'.
qtr(4) = sy-datum(4).
qtr+4(4) = '0701'.
lqtr(4) = sy-datum(4) - 1. --- newly added
lqtr+4(4) = '0701'. --- newly added
elseif sy-datum4(2) = '10' or sy-datum4(2) = '11' or sy-datum+4(2) =
'12'.
qtr(4) = sy-datum(4).
qtr+4(4) = '1001'.
lqtr(4) = sy-datum(4) - 1. --- newly added
lqtr+4(4) = '1001'. --- newly added
endif.
write: qtr.
write: lqtr. --- newly added
Message was edited by: ravi raj -
Display Current Quarter and Previous Quarter???
Hi Gurus,
I Had a requirement to display only the current Quarter and previous quarter in the report level using single quarter column.
and my quarter value type is Q1 2013.
Please anyone help me out on this asap/
Thanks.Hi,
Using time serious function you can acheive this requirement.
http://obieetutorialguide.blogspot.in/2012/02/modeling-time-series-function-in-obiee.html
OBIEE 11g Time Series Function
or,
Using presentation variable you can achieve this.
Re: OBIEE 10g LY YTD returns YTD for past years
The above thread for year you can change to qtr.
Hope this help's
Thanks,
Satya -
How to Display Current Quarter results in WebI report?
Hi Guys,
I have a requirement where a WebI report should open up on current quarter basis by default. I have checked the refresh on Open in the document properties.What changes or formulae do I need to make/create in order to open the report with current quarter results?
Appreciate any help.
Thanks & Regards,
Anila.Hi Anila,
Do you mean if a user is running a report on the first quarter, the report should display data for the first quarter only?
If yes, here is the solution:
Create a formula:
CurrQtr = If (Quarter(CurrentDate())) = MyQuarterObject THEN "Show"
Then put a ReportFilter CurrQtr=Show
Regards,
Ashvin -
Need to display the Current Quarter Data
Hi Gurus,
We have a requirement in the report as follows:
I have a Key Figure - 0Balance. In this it should display the current quarter data.
We have 5 plants and this report is specific to a plant X which runs 3 month behind.
So in the variables screen, if I enter 006.2007, it should display the data of 003.2007. Please guide me through the steps...Thanks in advance.Hi,
For getting current quarter data there is std variable available 0CMCQUAR , restrict KF wiht the variable and system should show you current quarter balance.
For getting balance for previous quarter , copy the kf just created and right click on it , click on the variable right hand side -> specify offset -> put -1. and it should give last quarter data.
Hope that helps.
Regards
Mr Kapadia -
Current quarter and future quarters
Hello Forum members:
Can you please advice me on this:
QUARTER SUM(CONFIG) Report_date
Q1-2007 10 12-Jan-2007
Q2-2007 10 21-Apr-2007
Q3-2007 870 14-Aug-2007
Q4-2007 50 14-Nov-2007
Q4-2006 897 15-Dec-2007
I want the following out put:
Please note that the future quarters should have current quarter sum(config)
Q4-2006 897
Q1-2007 10
Q2-2007 10
Q3-2007 870
Q4-2007 50
Q1-2008 50
Q2-2008 50
Q3-2008 50
Q4-2008 50
My query returns the following:
Q4-2006 897
Q1-2007 10
Q2-2007 10
Q3-2007 870
Q4-2007 50
select quarter, sum(config)
from quarter_test
where rep_Date >= ADD_MONTHS(TRUNC(SYSDATE,'q'),-12) AND
rep_date < ADD_MONTHS(TRUNC(SYSDATE,'q'),15)
group by quarter
order by substr(quarter,-4), substr(quarter,2,1);create table test5(quarter varchar2(7), config number, report_date date)
select * from test5
QUARTER CONFIG REPORT_DATE
Q1-2007 10 1/12/2007
Q2-2007 10 4/21/2007
Q3-2007 870 8/14/2007
Q4-2007 50 11/14/2007
Q4-2006 897 12/15/2007
select quarter, config from
(select quarter, sum(config) config
from test5
where report_Date >= ADD_MONTHS(TRUNC(SYSDATE,'q'),-12) AND
report_date < ADD_MONTHS(TRUNC(SYSDATE,'q'),15)
group by quarter
order by substr(quarter,4,4), substr(quarter,1,2))
union all
select 'Q'|| rownum || '-' || quarter, config from
select substr(quarter,4,4)+1 quarter, config from
select quarter, sum(config) config
from test5
where report_Date >= ADD_MONTHS(TRUNC(SYSDATE,'q'),-12) AND
report_date < ADD_MONTHS(TRUNC(SYSDATE,'q'),15)
group by quarter
order by substr(quarter,4,4) desc, substr(quarter,1,2) desc
where rownum=1)
test, all_objects where rownum <=4
QUARTER CONFIG
Q4-2006 897
Q1-2007 10
Q2-2007 10
Q3-2007 870
Q4-2007 50
Q1-2008 50
Q2-2008 50
Q3-2008 50
Q4-2008 50 -
Current quarter and four future quarters
Hello Forum Members,
I have a config table with the following data:
Quarter Config Rep_date
Q1-2006|1|1/1/2006
Q2-2006|32|4/12/2006
Q3-2006|321|7/15/2006
Q4-2006|897|12/14/2006
Q1-2007|10|2/12/2007
Q2-2007|10|5/12/2007
Q4-2007|50|11/12/2007
Q1-2008|30|1/1/2008
Q2-2008|57|4/10/2008
Q4-2008|45|12/12/2008
Q3-2008|34|8/8/2008
Q4-2005|21|12/1/2005
Q3-2005|20|8/22/2005
Q2-2005|65|4/14/2005
Q1-2005|65|1/14/2005
Q3-2007|435|9/9/2007
I have to show current quarter and four future quarters in oracle form.
ie
Q4-2007|50|
Q1-2008|30|
Q2-2008|57|
Q3-2008|34|
Q4-2008|45|
Please advise me.
ThanksComing at it from a different angle, you could fix the data before doing the query. This makes the query much simpler, which is good if it has to be used in many places in the application. Obviously the best way would be to make the quarter column a date column, but that's not always possible. A view or a function-based index can do the same job:
DROP TABLE quarters;
CREATE TABLE quarters AS
SELECT a quarter, b config, To_Date(c,'MM/DD/YYYY') rep_date FROM(
SELECT 'Q1-2006' a, 1 b, '1/1/2006' c FROM dual UNION ALL
SELECT 'Q2-2006', 32, '4/12/2006' FROM dual UNION ALL
SELECT 'Q3-2006', 321, '7/15/2006' FROM dual UNION ALL
SELECT 'Q4-2006', 897, '12/14/2006' FROM dual UNION ALL
SELECT 'Q1-2007', 10, '2/12/2007' FROM dual UNION ALL
SELECT 'Q2-2007', 10, '5/12/2007' FROM dual UNION ALL
SELECT 'Q4-2007', 50, '11/12/2007' FROM dual UNION ALL
SELECT 'Q1-2008', 30, '1/1/2008' FROM dual UNION ALL
SELECT 'Q2-2008', 57, '4/10/2008' FROM dual UNION ALL
SELECT 'Q4-2008', 45, '12/12/2008' FROM dual UNION ALL
SELECT 'Q3-2008', 34, '8/8/2008' FROM dual UNION ALL
SELECT 'Q4-2005', 21, '12/1/2005' FROM dual UNION ALL
SELECT 'Q3-2005', 20, '8/22/2005' FROM dual UNION ALL
SELECT 'Q2-2005', 65, '4/14/2005' FROM dual UNION ALL
SELECT 'Q1-2005', 65, '1/14/2005' FROM dual UNION ALL
SELECT 'Q3-2007', 435, '9/9/2007' FROM dual
CREATE OR REPLACE FUNCTION get_qtr_date(p IN VARCHAR2) RETURN DATE DETERMINISTIC AS
BEGIN
RETURN Add_Months(Trunc(To_Date(SubStr(p,4),'YYYY'),'YYYY'), (To_Number(SubStr(p,2,1))-1)*3);
END;
CREATE INDEX function_based ON quarters(get_qtr_date(quarter));
SELECT * FROM quarters
WHERE get_qtr_date(quarter) BETWEEN Trunc(SYSDATE-100,'Q') AND Add_Months(Trunc(SYSDATE-100,'Q'), 12)
ORDER BY get_qtr_date(quarter);
QUARTER CONFIG REP_DATE
Q3-2007 435 09-SEP-07
Q4-2007 50 12-NOV-07
Q1-2008 30 01-JAN-08
Q2-2008 57 10-APR-08
Q3-2008 34 08-AUG-08Another benefit of a function-based index on a column which has to take a specific format is that you can validate the data on the way in rather than checking it on the way out. For example:
CREATE OR REPLACE FUNCTION get_qtr_date(p IN VARCHAR2) RETURN DATE DETERMINISTIC AS
BEGIN
IF InStr(p,'Q') != 1 THEN
Raise_Application_Error(-20000, 'Invalid quarter format');
END IF;
RETURN Add_Months(Trunc(To_Date(SubStr(p,4),'YYYY'),'YYYY'), (To_Number(SubStr(p,2,1))-1)*3);
END;
INSERT INTO quarters VALUES('P3-2009',100,To_Date('10/10/2009','DD/MM/YYYY'));
ORA-20000: Invalid quarter format
ORA-06512: at "TEST.GET_QTR_DATE", line 4
Maybe you are looking for
-
Salesforce and report parameters
When I create a report using the Crystal Reports client I can set a parameter to use for the report, but when I upload the report to Salesforce I am stuck with whatever the last value I used in the client. How can I prompt the user for a value from
-
Safari can't be installed on this disk - It wants 10.6.7 I have 10.6.8
Safari was playing up with errors so I decided to trash it and download the latest version to see if it would fix teh problem - when I went to install it I got the following message; safari can't be installed on this disk - Thjis update requires 10.6
-
Has anyone submitted a successful application for the up-to-date program?
has anyone submitted a successful application for the up-to-date program? I submitted my application 2 days ago and when I log on it's still under review. Has anyone had difficulty with this? When they finally get back to me am I likely to be offere
-
Can't leave "Set Up Your iPod"
This is over week 3 with these issues. First it was "corrupt and unreadable" now I finally got though to the restore button and have restored it about 5 times. I have also changed the drive name to try to fix this. Any change I make, adding tracks, i
-
Help Viewer Font Size Way Too Small
Hello, The font size of the adobe help viewer content is way too small (it looks like a 4 pt or something). I can hardly read it at all. Can someone please tell me how to enlarge it? Thanks a lot! Mike