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
Similar Messages
-
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. -
Displaying current year and previous year's data.
hi all,
we have fields like doc.no, company code, costcenter, posting date, year etc... in a query.
we are using this query to display data in VC,
how can i display the current year and previous year's data in two different tables using the available fields.
any help will be highly appreciated.
thanks,
RkHi Rk,
You can achieve your requirement using 'Filter' operator. Drag one 'Filter' operator into visual composer story board and drag the output into filter and add condition(Check year=2008) and drag one table from filter. For another table use another filter and change the condition.
Hope it helps...
Regards
Basheer -
BEx - Display current year and previous year by day on the same row
Hello experts, need some help/suggestions on how I can accomplish the following please.
We have a requirement to show MTD revenue by day for the current year and previous year. The desired result will have the following columns
Calendar Day | Current MTD Revenue | Prev MTD Revenue
11/01/2009 | 15,131,005 | 15,138,668
11/02/2009 | 15,055,345 | 15,523,762
However, the result is showing up as follows:
Calendar Day | Current MTD Revenue | Prev MTD Revenue
11/01/2008 | | 15,138,668
11/02/2008 | | 15,523,762
11/01/2009 | 15,131,005 |
11/02/2009 | 15,055,345 |
The number of rows for Calendar Day varies depending on the date the user selects. We only want to display the days for the current year with the Previous Year Column on the same row.
Can someone please let me know how I can get the results to display on one line for each day?
Thanks,
DavidI have the same issue on my end, and am interested in responses. I searched the forum and found this suggestion in another post; not sure if this solution will help, but it looks like it might. This was a response from poster RadhaN:
RadhaN
Posts: 390
Registered: 8/27/09
Forum Points: 876
Re: a simple query to show sales versus last year on daily basis/
Posted: Sep 21, 2009 9:53 AM in response to: Shlomi Weiss Reply
HI Shlomi
Create a virtual characteristic in your infoprovider that can calculate the day from calendar Day. In ZXRSRZZZ while adding code for this virtual characteristic use the function module DATE_COMPUTE_DAY to compute the day for every calendar day.
For calculating Sales Current year, create a restricted ky figure with Sales as the key figure. Add 0CalDay to this RKF and create a variable for this infoobject(Eg: ZCURYEAR) that will receive input from the user for the range of dates eg: 08/16/2009 - 08/22/2009.
For Sales Prior year, create another restricted key figure with Sales. Add 0CalDay to this RKF and add a customer exit variable. In the Customer exit code use the ZCURYEAR variable and offset it to prior year in both the upper and lower limits. This should work.
I hope this helps.
Thanks. -
How to display current postion and previous position in the same row?
I need to produce a promotions/transfer report that gives the employee's current position as well as his/her previous position in the same row.
for example:
Employee current position current organization current company previous postion previous organization previous company
Jane Smith Executive PA ZYX ltd Harmony personal assistant ABC ltd Yahoo
I am using the per_all_people_f, per_all_assignments_f, per_periods_of_service, hr.all_organization_units, per_all_positions tables
Somehow i cannot manage to display the previous position. I can only get so far to display the current postions
Any ideas? here is the full code
--this query gives current info
select ppf.employee_number, ppf.full_name
, (DECODE (ppf.sex, 'M', 'Male', 'F', 'Female') ) gender
, (DECODE (ppf.per_information4
,'01', 'Indian'
,'02', 'African'
,'03', 'Coloured'
,'04', 'White') ) race
, ppf.ORIGINAL_DATE_OF_HIRE
, paf.EFFECTIVE_START_DATE current_postion_start_date
, RTRIM (SUBSTR (hpt.NAME, 1, INSTR (hpt.NAME, ';') ),';')Current_Position
, ho.name Current_Organization
, xx_return_structures.xx_return_company_name
(paf.person_id,
paf.effective_start_date
) current_company
from per_all_assignments_f paf,
hr_all_positions_f_tl hpt,
hr_all_organization_units_tl ho,
per_all_people_f ppf
--where paf.person_id = 16170
and paf.POSITION_ID=hpt.POSITION_ID
and paf.ASSIGNMENT_NUMBER is not null
and ho.organization_id = paf.organization_id
and ppf.person_id=paf.person_id
and paf.EFFECTIVE_START_DATE between ppf.EFFECTIVE_START_DATE and ppf.EFFECTIVE_END_DATE
order by paf.EFFECTIVE_START_DATE
--this query gives previous position, organization and company
select ass.EFFECTIVE_START_DATE
, RTRIM (SUBSTR (hpt.NAME, 1, INSTR (hpt.NAME, ';') ),';')Previous_Position
, ho.NAME previous_organization
, xx_return_structures.xx_return_company_name
(paf.person_id,
paf.effective_start_date
) previous_company
from per_all_assignments_f paf, hr_all_positions_f_tl hpt, hr_all_organization_units_tl ho
where paf.person_id = 16170
and paf.EFFECTIVE_START_DATE not in (select max(paf.EFFECTIVE_START_DATE)
f rom per_all_assignments_f paf
where ass.person_id = 16170)
and paf.PRIMARY_FLAG ='Y'
and paf.POSITION_ID=hpt.POSITION_ID
and paf.ORGANIZATION_ID=ho.ORGANIZATION_IDOk so here is my problem. The current position display 3 times. The rest is correct. it only display once. Any ideas on how to get rid of the 2 extra rows that is being displayed with the current position?? I only need the current position to display once with the previous position info.
select distinct pvs.person_id,
peo.EMPLOYEE_NUMBER empno,
peo.FULL_NAME,
(DECODE (peo.sex, 'M', 'Male', 'F', 'Female') ) gender,
(DECODE (peo.per_information4
,'01', 'Indian'
,'02', 'African'
,'03', 'Coloured'
,'04', 'White') ) race,
peo.ORIGINAL_DATE_OF_HIRE,
pvs.EFFECTIVE_START_DATE curr_start_date,
RTRIM (SUBSTR (pvs.job, 1, INSTR (pvs.job, ';') ) ,';') current_position,
pvs.ORGANIZATION current_organization,
substr(pvs.PAYROLL,5)current_company,
a1.previous_position,
a1.previous_organisation,
a1.previous_company
from per_periods_of_work_v pv,
per_assignments_v2 pvs,
per_all_people_f peo,(select distinct RTRIM (SUBSTR (pvs.job, 1, INSTR (pvs.job, ';') ) ,';') previous_position,
pvs.ORGANIZATION previous_organisation,
substr(pvs.PAYROLL,5)previous_company,
pvs.job_id job_id,
pvs.organization_id,
pvs.position_id,
pvs.location_id,
pvs.PERSON_ID,
pvs.PEOPLE_GROUP_ID,
pvs.EFFECTIVE_END_DATE,
pvs.EFFECTIVE_START_DATE
from per_assignments_v2 pvs
where sysdate > pvs.EFFECTIVE_END_DATE
and pvs.person_id=4723
)a1
where peo.person_id = pvs.person_id
and pvs.person_id = pv.person_id
and a1.person_id = pvs.person_id
and pvs.EFFECTIVE_START_DATE between peo.EFFECTIVE_START_DATE and peo.EFFECTIVE_END_DATE
and pvs.PEOPLE_GROUP_ID <> a1.people_group_id
and pvs.JOB_ID <> a1.job_id
and pvs.ORGANIZATION_ID <> a1.organization_id
and pvs.position_id <> a1.position_id activating this elimnates 1-Feb-2008 info
and pvs.effective_start_date -1 = a1.effective_end_date activating this eliminates 1-feb-2008, 1-jul-2006, 1-april-1996 info
and pv.person_id = 4723
order by pvs.effective_start_date desc -
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') -
Parameter for Current Month and Previous Month
I'm trying to create a parameter for current month and previous month based on the ex_date, but not sure what i'm doing wrong.
where ex_date = @SelectDate
I created a second dataset below for the values in the parameters.
SELECT Month(CURRENT_TIMESTAMP) AS 'Month', 'Current Month' as 'Current Month'
union all
SELECT Month(CURRENT_TIMESTAMP)-1 AS Month, 'Previous Month' as 'Previous Month'
Results
Month Current Month
3 Current Month
2 Previous Month
Once I preview it I get "Conversion failed when converting date and/ or time from character string" I changed the data type to "date/Time" but that did not make a difference. The date is convert (varchar(10), ex_date, 101) so looks like
11/12/2014.
I've also tried expressions like =month(now()) to pull current month with same error so i'm not sure what i'm doing wrong. Any ideas?i tired this real simple report
in the first dataset - my main report query - select name from sysdatabases where month(crdate())=@month
in the second dataset - select month(getdate()) as Month1
in the parameters - choose int data type and available values - select the second data set
in the first data set- add this parameter..( i am assumming you know this, since you have done)
in the preview you should get the drop down with current month number - 3
and if you run the report, it will display the database names that were created in march. remember we are no checking year, so will get all that were created in march across the years.
Hope it Helps!!
I'm looking to have the dropdown say "Previous Month" and "Current Month" as a option. I know how to get the information in SQL, but not sure how this translates or put into a parameter.
Current Month
list_date BETWEEN
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)
AND
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0)
Previous Month
list_date between
CONVERT(varchar,dateadd(d,-(day(dateadd(m,-1,getdate()-2))),dateadd(m,-1,getdate()-1)),106) /* Last Month */
and
CONVERT(varchar,dateadd(d,-(day(getdate())),getdate()),106) -
How to get data for current week and previous week using customer exit in Bex.
Hi everyone,
I have a scenario in which I need to display data for current week and previous week (based on "sy_datum" the program has to calculate current week and previous week) in Bex using Customer exit. I have created one variable in Bex Query Designer and I have written code for the variable in CMOD. But it is not working fine, (I know that we can do the same by using offset value in Bex). Can some one guide me how to achieve my requirement using customer exit.
Thanks in Advance,
G S Ramanjaneyulu.Hi krishna,
Thanks for your quick reply, can you have a look at my code,
case i_vnam.
WHEN 'ZPWK_CWK'.
ranges : pre_week for sy-datum.
data : start_date type DATS,
end_date TYPE dats .
************FM TO GET FIRST DATE OF CURRENT WEEK ************************
CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY'
EXPORTING
DATE_IN = sy-datum
IMPORTING
DATE_OUT = start_date. " WEEK FIRST DATE
end_date = START_DATE + 6. " WEEK LAST DATE
END_DATE = START_DATE - 1. " PREVIOUS WEEK END DATE
START_DATE = START_DATE - 7. " PREVIOUS WEEK START DATE
**********PREVIOUS WEEK DATES IN PRE_WEEK******************
pre_week-SIGN = 'I'.
pre_week-option = 'BT'.
pre_week-LOW = START_DATE.
pre_week-HIGH = END_DATE.
APPEND pre_week.
CLEAR : START_DATE,END_DATE.
endcase.
Regards,
G S Ramanjaneyulu. -
Parameter for current year and previous year
Hi all,
I currently have 2 reports where the query is the same except in the where clause I have it filtered to current year and previous year based on the List_Date. I would like to make this one report with a parameter of Current or Previous year.
Would I create 2 more datasets one for current and another for previous? I would think there is a easier way. Any help or direction would be great.If you define a parameter in SSRS, you can use it's value in your query. Just make sure the parameter name, and CASE (SSRS is case sensitive when it comes to parameters) are the same in SSRS and your query. There's a parameter tab on the dataset properties.
It SHOULD auto fill, but it never hurts to check, just in case.
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.
Yes it did auto fill the parameter tab in the dataset and I get a parameter to enter the year when I preview the report. Still a little confused on how I do current or previous year. Are the next steps what I need to do?
@yearParam parameter:
1) Create Available or Default values
2) Current and Previous year as label
3) For Value do I need to use a expression for current year =Year(now()) and previous Year?
4) Add a filter on the tablix for list_date? -
Difference between current row and previous row in a table
Hi All,
I am having a problem with the query. Can some of please help me?
I need to get difference between current row and previous row in a table. I have a table, which have data like bellow.
TABLEX
================
Name Date Items
AAA 01-SEP-09 100
BBB 02-SEP-09 101
CCC 03-SEP-09 200
DDD 04-SEP-09 200
EEE 05-SEP-09 400
Now I need to get output like bellow...
Name Date Items Diff-Items
AAA 01-SEP-09 100 0
BBB 02-SEP-09 101 1
CCC 03-SEP-09 200 99
DDD 04-SEP-09 200 0
EEE 05-SEP-09 400 200
Can some one help me to write a query to get above results?
Please let me know if you need more information.
Thanks a lot in advance.
We are using Oracle10G(10.2.0.1.0).
Thanks
Asif, nvl (items - lag (items) over (order by dt), 0)like in
SQL> with test as
2 (
3 select 'AAA' name, to_date('01-SEP-09', 'dd-MON-rr') dt, 100 items from dual union all
4 select 'BBB' name, to_date('02-SEP-09', 'dd-MON-rr') dt, 101 items from dual union all
5 select 'CCC' name, to_date('03-SEP-09', 'dd-MON-rr') dt, 200 items from dual union all
6 select 'DDD' name, to_date('04-SEP-09', 'dd-MON-rr') dt, 200 items from dual union all
7 select 'EEE' name, to_date('05-SEP-09', 'dd-MON-rr') dt, 400 items from dual
8 )
9 select name
10 , dt
11 , items
12 , nvl (items - lag (items) over (order by dt), 0)
13 from test
14 ;
NAM DT ITEMS NVL(ITEMS-LAG(ITEMS)OVER(ORDERBYDT),0)
AAA 01-SEP-09 100 0
BBB 02-SEP-09 101 1
CCC 03-SEP-09 200 99
DDD 04-SEP-09 200 0
EEE 05-SEP-09 400 200
SQL> -
How to display Current Year and Month in Drop Down list
Hi Dear friends,
I am devloping a report. It has got 2 pages--input and output(Report) page.
IN input page, user will select Month and Year from drop down list as one of the input parameters. (seperate drop down list 4 month and year)
Now, my problem is:
HOw to display current month and year by default in the dropdown list...........
I hope my question is clear.
Please help.
Regards,
AShNO da,
it is not working.
First i tired with for-loop. I initialized variable "i" to -2 (i=-2) I would get the year drop down list from 2003 but, by default 2003 would come.
So, i posted the question.
I tried your code. It is giving following error.
A Servlet Exception Has Occurred
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occured between lines: 122 and 127 in the jsp file: /test/inpt.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:182: Invalid type expression.
first.set(Calendar.YEAR, 2003)
^
An error occured between lines: 127 and 131 in the jsp file: /test/inpt.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:186: Invalid declaration.
out.write("\r\n \r\nYear : \r\n \r\n"); ^ An error occured between lines: 198 and 203 in the jsp file: /test/inpt.jsp Generated servlet error: C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:282: Invalid type expression. first1.set(Calendar.YEAR, 2003) ^ An error occured between lines: 203 and 207 in the jsp file: /test/inpt.jsp Generated servlet error: C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:286: Invalid declaration. out.write("\r\n \r\nYear :\r\n \r\n");
^
4 errors
Pls. Help.
Regards,
Ashu -
How to display current date and time together in pl sql block
i have written code below but it gives me error
SET SERVEROUTPUT ON
DECLARE
TODAY DATE;
BEGIN
SELECT CURRENT_DATE || TO_CHAR(CURRENT_DATE, 'FM HH:MI:SS AM') INTO TODAY
FROM DUAL;
DBMS_OUTPUT.PUT_LINE('TODAY');
END;
ERROR at line 3:
ORA-01830: date format picture ends before converting entire input string
ORA-06512: at line 4Here's how you do it:
DECLARE
TODAY varchar2(100);
BEGIN
SELECT TO_CHAR(CURRENT_DATE, 'MM-DD-YYYY HH:MI:SS AM') INTO TODAY
FROM DUAL;
DBMS_OUTPUT.PUT_LINE(TODAY);
END;
Notes:
1. You select to_char(...) into today, so today should be declared as char, not date.
2. dbms_output.put_line('today') will print "today", you want to print the variable not the string, so no quotes.
3. date variables contain both date and time, no need to concatenate -
Current year and previous year
Hi All Grus,
i have a one requirement user will give input 30.04.2009 . the output should show last ten days including user entered date like 21.04.2009 to 30.04.2009 for current year and previous year
this current year and previous should show column wise in row wise i need year like given below
user input: 30.04.2009
row column
21.04.09 22..04.09. 23..04.09 .............................................................. 30.04.2009
2009 100 200 300 ............................................................... 500
2008 200 300 600 ................................................................. 1000
Edited by: kek.uthayakumar on Aug 4, 2009 7:57 AM
Edited by: kek.uthayakumar on Aug 4, 2009 7:58 AMHi
You need to have customer exit variable on this calday and write code to obtain your logic. Search in SDN for sample codes:
enter information required in search forum SAP Business Explorer (SAP BEx)
Regards
Ravi -
Queries for current Qtr and prior quarter
If I select one date in dashboard prompt in one column I want to display current quarter revenue and prior Qtr revenue.
Could anyone give me the queries for the current Qtr and prior Qtr?
So I will going to use presentation variable from the dashboard promptsobiee-date-expressions-reference
Date Calculation OBIEE Expression Explanation :
First Day of the Previous Year
TIMESTAMPADD( SQL_TSI_YEAR , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD removes a year from the returned date for the First Day of the Previous Year.
First Day of the Current Year
TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE) This calculation returns the first day of the year by deducting one less than the total number of days in the year.
First Day of the Next Year
TIMESTAMPADD( SQL_TSI_YEAR , 1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD adds a year to the date returned which will give the first day of the next year.
First Day of the Previous Month
TIMESTAMPADD(SQL_TSI_MONTH, -1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD then subtracts one month from the first day of the Current Month arriving to the First Day of the previous month.
First Day of the Current Month
TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE) This expression gets the current day of the month and subtracts one less than the current day to arrive at the first day of the month.
First Day of the Next Month
TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD then adds one month from the first day of the Current Month arriving to the First Day of the next month.
First Day of Current Quarter
TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE) This was included to show the calculations discussed above can be used with other functions. This is the same expression as the one that returns the first day of the current month except this one uses the DAY_OF_QUARTER property to return the first day of the current quarter.
Last Day of the Previous Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD subtracts a month to arrive at the first day of the previous month.
Last Day of Current Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) From right to left the first TIMESTAMPADD finds the first day of the current Month. The second TIMESTAMPADD adds one month to the date to arrive at the first day of the next month. The final TIMESTAMPADD subtracts one day from the returned date to arrive at the last day of the Current Month.
Last Day of the Next Month
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 2, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) From right to left the first TIMESTAMPADD finds the first day of the current Month. The second TIMESTAMPADD adds two months to the date to arrive at the first day of month after next. The final TIMESTAMPADD subtracts one day from the returned date to arrive at the last day of the Next Month.
Last Day of Previous Year
TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1,
CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD subtracts one day to arrive at December 31st of the previous year.
Last Day of Current Year
TIMESTAMPADD(SQL_TSI_YEAR, 1, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD deducts one day to arrive at December 31 of the previous year. The third TIMESTAMPADD adds a single year to the date to arrive at December 31 of the Current Year.
Last Day of the Next Year
TIMESTAMPADD(SQL_TSI_YEAR, 2, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD deducts one day to arrive at December 31 of the previous year. The third TIMESTAMPADD adds 2 years to the date to arrive at December 31 of the Next Year.
Last Day of Current Quarter
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_QUARTER , 1, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) Demonstrated using Quarters. From right to left the first TIMESTAMPADD returns the first day of the Current Quarter. The second TIMESTAMPADD returns the first day of the next quarter. The final TIMESTAMPADD subtracts a single day from the date to arrive at the last day of the Current Quarter.
Number of days between First Day of Year and Last Day of Current Month TIMESTAMPDIFF(SQL_TSI_DAY, CAST('2010/01/01 00:00:00' AS DATE), TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))) For simplicity I hard coded the January 1, 2010 date and CAST it to a date. I could have used the First Day of the Current Year calculation but didn’t want to over clutter the example. The second part of the TIMESTAMPDIFF uses Last Day of the Current Month calculation to force the TIMESTAMPDIFF to calculate the number of days between the first day of the year and the last day of the current month.
=============
FYI, let say some example,
Last day of previous Quarter:
"GPC_DataMart"."GPC_DataMart"."dbo"."LQ_Position"."Business_Date"=TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date") * -(1) + 1, "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date"))
Last month last day:
"GPC_DataMart"."GPC_DataMart"."dbo"."LM_Position"."Business_Date"=
TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date") * -(1) + 1, "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date"))
Last year Last day
"GPC_DataMart"."GPC_DataMart"."dbo"."LY_Position"."Business_Date"=
TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date") * -(1) + 1, "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date"))
Thanks and Regards,
Deva
http://obieeelegant.blogspot.com/2011/06/obiee-date-expressions-reference.html -
Select statement for last day of the last quarter and first quarter
Anybody provide me the single select statement which should result the last day of the last quarter and last day of current quarter?
Ex: Select last date of the last quarter,last day of current quarter from XYZ(DUAL...)
Thanks in AdvanceHi,
Here's one way:
SELECT TRUNC (SYSDATE, 'Q') - 1 AS prev_qtr_end
, ADD_MONTHS ( TRUNC (SYSDATE, 'Q') - 1
, 3
) AS this_qtr_end
FROM dual;TRUNC (dt, 'Q') returns the first day of the quarter containing dt.
Subtract one day from that, and you have the last day of the previous quarter.
Add 3 months to that, and you have the last day of the current quarter. ADD_MONTHS (dt, n) will always return the last day of a month if its first argument, dt, is the last day of a month.
Maybe you are looking for
-
I want to control the flow of data, by a SWITCH. I have a data flow which I want it to flow through a particular code, when I press that SWITCH, the data flow should be blocked and the code should use the previous values stored to calulate further.
-
OCR corrupt how to reinstall Acrobat 9 Pro
My OCR function in Acrobat 9 Pro says it is corrupt. I have tried to fix it and no repaid has worked. how do I reinstall 9 Pro, where do I get the download. It isn't in my account settings. I have my serial numbers.
-
Error when opening a B1 generated PDF
Hi, I have a client who has a problem with exported PDFs. The export from B1 appears to go smoothly, but when opening the PDF after export they get a error message from Acrobat Reader stating "this is not a supported format, or the file is damaged".
-
My MBP died - Apple's 5-star service
My late '07/early '08 MBP died tonight. The start up chime just keeps repeating ad infinitum. Googling suggests that it's a main logic board failure. My AppleCare warranty expired last week I rang Apple Support anyway as I've heard tell that they can
-
How do I fix my damaged screen?
I dropped my Iphone 4s and my screen has colored lines going vertical. It lights up and dims when I lock it and unlock it. I don't know if its fixable, I'm just wondering if theres an easy fix. My phone still works. It vibrates when misstype my passc