[HELP] AGO function return wrong result
Hi, i try to implement ago function in OBIEE, but the result is not as expected. Please help me to configure Time Dimension to get this work.
My case:
- I have a time dimension with this configuration:
[http://i264.photobucket.com/albums/ii176/necrombi/NEO/1-1.png]
Time Hierarchy: Total > Year > Quarter > Month > Day
Year:
Primary key: Calendar_year_cal_year_code
Chronological key: Does not define
Quarter:
Primary key: Calendar_quarter_description
Chronological key: Does not define
Month:
Primary key: Calendar_month_description
Chronological key: Calendar_month_description
Day:
Primary key: Dimension_key
Chronological key: Day_day_code
My ago function: AGO(expression, mywh.D_qn_thoigianDim."month", 1)
I do not understand why i get this wrong results:
[http://i264.photobucket.com/albums/ii176/necrombi/NEO/2.png]
Does anyone know how to solve this?
Edited by: 864451 on Jun 8, 2011 5:11 AM
Hi, thanks for your reply.
I implemented Time dimension with your recommend, and have time dimension like this:
Time Hierarchy: Total > Year > Quarter > Month > Day
Year:
Primary key: Calendar_year_start_date
Chronological key: Calendar_year_start_date
Quarter:
Primary key: Calendar_quarter_start_date
Chronological key: Calendar_quarter_start_date
Month:
Primary key: Calendar_month_start_date
Chronological key: Calendar_month_start_date
Day:
Primary key: Day
Chronological key: Dimension_key
And Ago function works fine with month level: AGO(expression, mywh.D_qn_thoigianDim."month", n)
But return sum result of 12 month with: AGO(expression, mywh.D_qn_thoigianDim."year", 1)
In my case, i just use AGO(expression, mywh.D_qn_thoigianDim."month", 12) to get year ago value. But i still don't understand clearly about OBIEE Time Serries functions.
Thanks,
Dung Nguyen
Similar Messages
-
HTMLDB_ITEM.SELECT_LIST function returns wrong result in 1.6?
Look at following select statements:
1. select flows_010600.htmldb_item.select_list(1,null,'Full;F,Read;R,No;N',
'','YES',null,'Derived','f01_'||TO_CHAR(ROWNUM,'FM0000'),'D')
from dual
<label for="f01_0001" class="hideMe508">D</label><select name="f01" id="f01_0001"><option value="">Derived</option><option value="F" >Full</option><option value="R" >Read</option><option value="N" >No</option><option value="" selected="selected"></option></select>
2.select flows_010500.htmldb_item.select_list(1,null,'Full;F,Read;R,No;N',
'','YES',null,'Derived','f01_'||TO_CHAR(ROWNUM,'FM0000'),'D')
from dual
<label for="f01_0001" class="hideMe508">D</label><select name="f01" id="f01_0001"><option value="">Derived<option value="F" >Full<option value="R" >Read<option value="N" >No</select>
If selected value of list is null version 1.6 call adds extra item without display value. Version 1.5 call works fine. Is it a bug or implied behavior?Hi Alexey,
This is the intended behavior; in your htmldb_item.select_list call, you are setting the current value to NULL. This is the value shown in 1.6. In 1.5 the first value from your list of values was shown. This behavior wasn't appropriate in most cases. If for example you had a tabular form with a select list and the values retrieved from the database were not part of the list of values used for the select list, it would basically default the select list to the first value from your list of values. If you then saved your tabular form, you would have ended up with the wrong data. Now the select list will show the actual value from the database, if it's not part of the list of values. Otherwise it will show the correct display value. If in your case this is not the behavior you need, you can simply turn that off by modifying your query to:
select flows_010600.htmldb_item.select_list(1,null,'Full;F,Read;R,No;N',
'','YES',null,'Derived','f01_'||TO_CHAR(ROWNUM,'FM0000'),'D','NO')
from dual
I simply added another attribute which is called p_show_extra and set it to 'NO'. Here's the full specification of the function:
function select_list (
p_idx in number,
p_value in varchar2 default null,
p_list_values in varchar2 default null,
p_attributes in varchar2 default null,
p_show_null in varchar2 default 'NO',
p_null_value in varchar2 default '%null%',
p_null_text in varchar2 default '%',
p_item_id in varchar2 default null,
p_item_label in varchar2 default null,
p_show_extra in varchar2 default 'YES'
) return varchar2
Hope this helps,
Marc -
Help - count function returns strange results
hi everyone,
here's my scenario: i'm trying to get the NUMBER OF REPORTS and NUMBER OF
IMAGES GROUP BY MONTH from the two tables below.
REPORT
reportid(*primary key)
date
IMAGE
reportid(*foreign key referring to report's table)
image
sample output:
MONTH NO.OF REPORTS NO. OF IMAGES
feb 01 10 9
mar 01 12 8
my SQL goes like this:
select to_char(date, 'month-yy'),
count(REPORT.reportid), count(IMAGE.reportid)
from REPORT, IMAGE
where REPORT.reportid = IMAGE.reportid
group by to_char(date, 'month-yy')
the above sql yielded strange results, number of images is equal to the number of reports, which is of course wrong! as one report may or may not contain one or more image.
i dont know what's wrong with the above statement, but if i were to group it
by REPORTID and DAY rather than MONTH, then amazingly it works! what's
wrong with the count, why does it give me the same result if i group by
MONTH.
can anyone shed some light on this?try using the following example:
Table TEST_REPORT
RPTID RPTDATE
1 02-JAN-01
3 02-JAN-01
2 02-JAN-01
5 11-FEB-01
6 11-FEB-01
7 11-FEB-01
Table TEST_IMAGE
RPTID IM
1 1
2 1
3 1
SQL:
select to_char(rptdate,'MON-YYYY'),
sum(decode(a.rptid,null,0,1)) report_cnt,
sum(decode(b.rptid,null,0,1)) image_cnt
from test_report a, test_image b
where a.rptid = b.rptid(+)
group by to_char(rptdate,'MON-YYYY');
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by skcedric:
hi everyone,
here's my scenario: i'm trying to get the NUMBER OF REPORTS and NUMBER OF
IMAGES GROUP BY MONTH from the two tables below.
REPORT
reportid(*primary key)
date
IMAGE
reportid(*foreign key referring to report's table)
image
sample output:
MONTH NO.OF REPORTS NO. OF IMAGES
feb 01 10 9
mar 01 12 8
my SQL goes like this:
select to_char(date, 'month-yy'),
count(REPORT.reportid), count(IMAGE.reportid)
from REPORT, IMAGE
where REPORT.reportid = IMAGE.reportid
group by to_char(date, 'month-yy')
the above sql yielded strange results, number of images is equal to the number of reports, which is of course wrong! as one report may or may not contain one or more image.
i dont know what's wrong with the above statement, but if i were to group it
by REPORTID and DAY rather than MONTH, then amazingly it works! what's
wrong with the count, why does it give me the same result if i group by
MONTH.
can anyone shed some light on this? <HR></BLOCKQUOTE>
null -
Please Help Urgent:Fast Search returning wrong result sets
Hi All,
We are facing below issue with fast search.
Currently in My project when we are searching for a phrase it is returning wrong result sets.
For example if we search for “Endura”, It is returning documents related to
Endura as well as Centura.
But the expected results are only Endura documents.
When we look in to the documents we didn’t find the search term (“Endura” ) either inside document content or in its meta data.
In order to resolve the issue we tried the below steps
1-
We manually edited and saved the document, to ensure the appropriate Guid association to metadata.
2-
Index reset
3-
Full crawl
But no luck so far.
Please help.Thanks in advance.
Regards
SubratSubrat,
This may be related to spellchecking or may be synonym. Spellcheck is based on indexed terms.
The best test would be to run the queries from qrserver (13280) and then look at the spellcheck query transformations. If spellchecking is not doing it, then you must have a synonym setup .Check your keyword/synonyms from the SharePoint side. -
Query returning wrong results - Help required.
Hi All,
I am having a query in which I have 10 records, 5 with stop time 1 and 5 with stop time 2.
I have a scenario in which, I need to calculate the maximum,minimum for the records
with stop time 1 and 2.
What I did is, I selected all the 10 records using for loop. Within the loop
I am trying to find the maximum and minimum. It is giving me wrong results.
Please help me. My code is follows
declare
v_p1_min_stop_tm number;
v_p1_max_stop_tm number;
v_p2_min_stop_tm number;
v_p2_max_stop_tm number;
begin
for i in(
select
stop_tm
from
sample_stop
where
map_nbr = 16645 and
stop_dt = '05-sep-08'
)loop
if i.stop_tm = 1 then
select
min(i.stop_tm),
max(i.stop_tm)
into
v_p1_min_stop_tm,
v_p1_max_stop_tm
from
dual;
elsif i.stop_tm = 2 then
select
min(i.stop_tm),
max(i.stop_tm)
into
v_p2_min_stop_tm,
v_p2_max_stop_tm
from
dual;
end if;
end loop;
dbms_output.put_line('minimum p1 stop time : '|| v_p1_min_stop_tm);
dbms_output.put_line('maximum p1 stop time : '|| v_p1_max_stop_tm);
dbms_output.put_line('minimum p2 stop time : '|| v_p2_min_stop_tm);
dbms_output.put_line('maximum p2 stop time : '|| v_p2_max_stop_tm);
end;
My o/p is :
Minimum P1 stop time : 523
Maximum P1 stop time : 523
Minimum P2 stop time : 719
Maximum P2 stop time : 719
Here how can I make the data as two sets, one set with stop time 1 and
other with stop time 2.
Regards
RaghuIf the data type of stop_tm is varchar then try following
declare
v_p1_min_stop_tm number;
v_p1_max_stop_tm number;
v_p2_min_stop_tm number;
v_p2_max_stop_tm number;
begin
for i in(select stop_tm from sample_stop
where
map_nbr = 16645 and
stop_dt = '05-sep-08'
)loop
if i.stop_tm = 1 then
select min(to_number(i.stop_tm)), max(to_number(i.stop_tm))
into v_p1_min_stop_tm,v_p1_max_stop_tm
from
dual;
elsif i.stop_tm = 2 then
select
min(to_number(i.stop_tm)), max(to_number(i.stop_tm))
into
v_p2_min_stop_tm,v_p2_max_stop_tm
from
dual;
end if;
end loop;
dbms_output.put_line('minimum p1 stop time : '|| v_p1_min_stop_tm);
dbms_output.put_line('maximum p1 stop time : '|| v_p1_max_stop_tm);
dbms_output.put_line('minimum p2 stop time : '|| v_p2_min_stop_tm);
dbms_output.put_line('maximum p2 stop time : '|| v_p2_max_stop_tm);
end;
/ Regards
Singh -
Spotlight returns wrong results
After installing Yosemite on my MacBook Pro, I tried to use Spotlight on some simple searches, with startling results. For example, I looked for Spotlight help...and a Word for Mac file opened. I recognize that Spotlight scours my Mac for material, but I do not understand why it would open a file that has nothing to do with the search terms.
Can anyone hazard a guess about what may be happening?Did it and it worked to add _spotlight to the ACLs but Spotlight still return blank results on AFP clients...
Do you know what should be the permissions on the .spotlight-V100 folder?
Spotlight works on the servers so the index is fine. It's the AFP clients that can't read it properly or don't get all the data from it. -
NODIM function Returns wrong values?
Hi All,
We have a KF Quantity in PC and we are using NODIM(Quantity) to diaply it without units.But
NODIM(Quantity) displays wrong results.
For Example:Quantity = 3123214 PC and NODIM(Quantity) = 3123214.123
What could be the reason for it?can anyone explain me?
Thanks
Message was edited by: MurliThanks for your wishes on the other post.
My advance wishes to you for the same..
Dear Murali,
I am not sure the following 'note' can help us.. please have a look..
Note number: 604857: ( Also have a look at 590089,730382)
Incorrect number of decimal places with NODIM operator
Symptom
The system produces an incorrect proposal for the number of decimal places for a structure element.
Other terms
Query, NODIM, decimals, decimal places
Reason and Prerequisites
The key figure uses the NODIM operator
Solution
BW 3.0B
Import Support Package 12 for 3.0B (BW 3.0B Patch 12 or SAPKW30B12) into your BW system. This Support Package will be available when note 523249 with the short text "SAPBWNews BW 3.0B Support Package 12", which describes this Support Package in more detail, is released for customers.
To provide information in advance, note 523249 may already be available before the Support Package is released. In this case, the short text will still contain the words "preliminary version".
BW 3.1C
Import Support Package 06 for 3.1C (BW 3.1C Patch06 or SAPKW31C06) into your BW system. This Support Package will be available when note 539827 with the short text "SAPBWNews BW 3.1C Support Package 06", which describes this Support Package in more detail, is released for customers. For more information on BW Support Packages, see note 110934.
In urgent cases, you can implement the correction instructions in your system using transaction SNOTE.
Regards,
Hari
Message was edited by: Hari Kiran Y -
WebService returning wrong result
Hi All,
I am trying to write a webservice but somehow getting wrong result. Not sure where i am going wrong. I am seeing following in logs -
Request envelop -
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<Multiply xmlns="http://tempuri.org/">
<A xsi:type="xsd:float" xmlns="">40.0</A>
<B xsi:type="xsd:float" xmlns="">20.0</B>
</Multiply>
</soapenv:Body>
</soapenv:Envelope>
Response -
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><MultiplyResponse xmlns="http://tempuri.org/"><MultiplyResult>0</MultiplyResult></MultiplyResponse></soap:Body></soap:Envelope>
This is a webservice available online url - http://samples.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx?op=Multiply
Please HELP!!! Thanks in advance.
-Tarunsend this and write the results...
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<m:Multiply xmlns:m="http://tempuri.org/">
<m:A>3.14159E0</m:A>
<m:B>3.14159E0</m:B>
</m:Multiply>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> -
Simple query with like return wrong result
Hi,
I run simple query with like.
If I use parameter I get wrong results.
If I use query without parameter results are ok.
My script:
ALTER SESSION SET NLS_SORT=BINARY_CI;
ALTER SESSION SET NLS_COMP=LINGUISTIC;
-- drop table abcd;
create table abcd (col1 varchar2(10));
INSERT INTO ABCD VALUES ('122222');
insert into abcd values ('111222');
SELECT * FROM ABCD WHERE COL1 LIKE :1; -- wrong result with value 12%
COL1
122222
*111222*
select * from abcd where col1 like '12%'; -- result ok
COL1
122222
I use Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
and query run in Oracle SQL Developer 3.1.07.Hi,
welcome to the forum.
When you put some code please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
You should specify exactly how you run your code.
If I run this statement in SQL Plus:SQL> ALTER SESSION SET NLS_SORT=BINARY_CI;
Session altered.
SQL> ALTER SESSION SET NLS_COMP=LINGUISTIC;
Session altered.
SQL>
SQL> -- drop table abcd;
SQL> create table abcd (col1 varchar2(10));
Table created.
SQL>
SQL> INSERT INTO ABCD VALUES ('122222');
1 row created.
SQL> insert into abcd values ('111222');
1 row created.
SQL>
SQL> SELECT * FROM ABCD WHERE COL1 LIKE :1;
SP2-0552: Bind variable "1" not declared.
SQL>
I got this error. So I wonder how you set value 12%
Please specify exactly how you run your test as we cannot reproduce your problem.
Regards.
Al -
Query returning wrong result set
I am running the following query on 8.1.7 database. The query is
SELECT Y.*, TEVStatus.lEndStatusFlag ENDSTATUSFLAG
FROM
(SELECT ROWNUM RANK, X.* FROM (SELECT lExceptionID ID,
TEVException.sMonitorName MONNAME, sExcpStatus STATUS
FROM TEVException WHERE (TEVException.lExceptionID IN
(SELECT lExceptionID FROM TEVException WHERE
sUserName_AssignedTo = 'vadmin')) ORDER BY
TEVException.lExceptionID DESC) X)
Y, TEVStatus WHERE (Y.RANK > 0 AND Y.RANK < 0 + 51 + 1) AND
(STATUS = TEVStatus.sStatusName);
The result is
RANK ID MONNAME STATUS ENDSTATUSFLAG
51 29 Type09B Open 0
50 30 Type09A Open 0
49 31 Type09E Open 0
48 32 Type09F Open 0
47 33 Type09G Open 0
46 34 Type09I Open 0
45 35 Type09C Open 0
44 36 Type10A Open 0
43 37 Type04A Open 0
39 41 Type08A Open 0
38 42 Type08C Open 0
RANK ID MONNAME STATUS ENDSTATUSFLAG
37 43 Type10B Open 0
36 44 Type10E Open 0
35 45 Type10C Open 0
34 46 Type10F Open 0
33 47 Type10D Open 0
32 48 Type08B Open 0
31 49 Type04B Open 0
29 51 Type08D Open 0
28 52 Type11E Open 0
27 53 Type11A Open 0
26 54 Type11D Open 0
RANK ID MONNAME STATUS ENDSTATUSFLAG
25 55 Type11C Open 0
24 56 Type11B Open 0
23 57 Type12A Open 0
22 58 Type12B Open 0
21 59 Type12C Open 0
20 60 Type12E Open 0
19 61 Type12A Open 0
18 62 Type12B Open 0
17 63 Type12E Open 0
16 64 Type12C Open 0
15 65 Type12D Open 0
RANK ID MONNAME STATUS ENDSTATUSFLAG
14 66 Type12D Open 0
4 80 Type01A_Ravi Open 0
3 83 Type01A_Ravi Open 0
2 84 Type01A_Ravi Open 0
1 87 Type01A_Ravi Open 0
42 38 Type06E Closed 8500
41 39 Type06A Closed 8500
40 40 Type06B Closed 8500
30 50 Type06C Closed 8500
13 68 Type01A Closed 8500
12 69 Type01A Closed 8500
RANK ID MONNAME STATUS ENDSTATUSFLAG
11 70 Type01A Closed 8500
10 71 Type01A Closed 8500
9 72 Type01A Closed 8500
8 73 Type01A Closed 8500
7 75 Type01A Closed 8500
6 77 Type01A Closed 8500
5 78 Type01A Closed 8500
51 rows selected.
In the above result, the RANK is not sorted properly and I
expected ID in descending order. The table which I was querying
had only about 100 records. I ran the same query on a larger
record set and the result is fine. I get ID in descending order
which I was expecting.
Could someone please tell me whether any bug in this case or
something wrong in the queryHi...
Took a quick look at tour SQL and....
SELECT Y.*
, TEVStatus.lEndStatusFlag ENDSTATUSFLAG
FROM ( SELECT ROWNUM RANK
, X.*
FROM ( SELECT lExceptionID ID
, TEVException.sMonitorName MONNAME
, sExcpStatus STATUS
FROM TEVException
WHERE ( TEVException.lExceptionID IN
( SELECT lExceptionID
FROM TEVException
WHERE sUserName_AssignedTo
= 'vadmin'
ORDER BY TEVException.lExceptionID DESC
) X
) Y
, TEVStat us
WHERE ( Y.RANK > 0
AND
Y.RANK < 0 + 51 + 1
AND STATUS = TEVStatus.sStatusName ;
Should "FROM ( SELECT ROWNUM RANK" be "FROM ( SELECT ROWNUM,
RANK"?
RANK is a reserved word, an analytic function.
Is "ORDER BY TEVException.lExceptionID DESC" doing anything? I
would drop it..
Hope this helps. Good Luck. -
Week function gives wrong result for last week in year
Week(CreateDate(2011,12,25)) returns 51 - correct
Week(CreateDate(2011,12,26)) returns 53 - wrong
It looks like all last weeks of the year are 53 whereas the next year with 53 weeks should be 2015.
See http://tuxgraphics.org/toolbox/calendar.html for example.
I am running CF9 on Windows 7 with Java V6 update 29.
This is causing me a problem. Any ideas for a workaround?
DougHere is my general solution for my cfc which seems to work for all dates up to 2100 at least.
Hope it can help if you need a Week function to replace the CF one.
<cffunction name="getISOWeekNum" access="public" returntype="Numeric" hint="Gets ISO week number in which date occurs.">
<cfargument name="date" type="date" required="true" hint="Date for which you wish to know the week number">
<cfset var weeknum = 0>
<cfset var isLeap = isLeapYear(Year(date))>
<cfset var dayInWeek = dayOfWeek(date)>
<cfset var isoDayOfWeek = iIf(dayInWeek GT 1, dayInWeek - 1, 7)>
<cfset var nearestThur = dateAdd("d", 4 - isoDayOfWeek, date)>
<cfset var fourthDayOfYear = createDate(year(nearestThur), 1, 4)>
<cfset var fourthDayInWeek = dayOfWeek(fourthDayOfYear)>
<cfset var fourthIsoDayOfWeek = iif(fourthDayInWeek GT 1, fourthDayInWeek - 1, 7)>
<cfset var firstThur = dateAdd("d", 4 - fourthIsoDayOfWeek, fourthDayOfYear)>
<cfset var lastWeek = iIf(fourthDayInWeek EQ 8 OR (isLeap AND fourthDayInWeek EQ 7), 53, 52)>
<cfset var firstIsoDayOfFirstWeek = dateAdd("d", -(fourthIsoDayOfWeek-1), fourthDayOfYear)>
<cfset var firstIsoDayOfLastWeek = dateAdd("d", -7, firstIsoDayOfFirstWeek)>
<cfset var lastIsoDayOfFirstWeek = dateAdd("d", 6, firstIsoDayOfFirstWeek)>
<cfset var weekDiff = iIf(dateCompare(date, firstIsoDayOfFirstWeek, "d") EQ -1, 0, 1)>
<cfif dateCompare(date, firstIsoDayOfFirstWeek, "d") EQ -1 AND dateCompare(date, firstIsoDayOfLastWeek, "d") NEQ -1>
<cfset weeknum = lastWeek>
<cfelseif dateCompare(date, lastIsoDayOfFirstWeek, "d") NEQ 1 AND dateCompare(date, firstIsoDayOfLastWeek, "d") NEQ -1>
<cfset weeknum = 1>
<cfelse>
<cfset weeknum = weekDiff + (dateDiff("d", firstThur, nearestThur) / 7)>
</cfif>
<cfreturn weeknum>
</cffunction>
Doug -
Directory search returns wrong results when you modify the view
Hello,
I have a custom list used a staff directory. This is SharePoint 2013. I am using a search box where users can type in names to find people.
When I add or remove a record in the list or modify the view and then I search for my name, all search results appear. It once just returned 1 record for my name, but now it returns all 100 records in the list.
How can I fix this?
Thanks,
Paul
PaulHi Paul,
Did you search in the SharePoint list or in SharePoint search center?
Could you provide more details about how you created the custom list?
Please try to enable Server Render as editing the page->Edit Web Part-> Miscellaneous, compare the result.
Please operate in other lists and in other site collections and test whether this issue occurs.
Please start a full crawl in Central Administration -> Manage service application -> Search service application -> Content Sources and test whether this issue occurs.
Could you check if it exists error in ULS log after you failed to search in the SharePoint list.
Best Regards,
Dean Wang
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
HELP!! Return Key results in multiple lines down
Everytime I press the return key, pages returns at least 10 lines. i can't figure out what is going wrong. PLEASE HELP
Put the cursor where you just hit return. Bring up the Text Inspector, Text panel. Check the settings under Spacing for Line, Before Paragraph and After Paragraph. Those all control how much space results when you hit enter.
You probably want Before Para and After Para to be at zero. You might need to select all text before making the change. -
MONTHS_BETWEEN function returning wrong negative values
Hello all,
The following is the query I am puzzling over:
select to_char(sysdate,'dd-MON-yyyy') AS TODAY, TO_CHAR(HYPOTHETICAL_DATE, 'dd-MON-yyyy') AS HYPOTHETICAL_DATE,
months_between(sysdate,HYPOTHETICAL_DATE) AS DIFF_IN_MONTHS from TableX
My result is:
TODAY HYPOTHETICAL_DATE DIFF_IN_MONTHS
21-MAR-2012 10-JUL-2020 -99,63109505675029868578255675029868578256
I am puzzled since in this case since the 2nd date is 8 years down the line my difference should be -8 and a fraction. So why am I getting -99?
Furthermore I would like to ignore the fractional part so the result I want for the above data is -8.
Please help.
Thanks
S. BASUThe name of the function is MONTHS_BETWEEN and not YEARS_BETWEEN. So the result is correct!
Perhaps you are looking for something like:
select trunc(months_between(sysdate,to_date('10.07.2020'))/12) from dual;or
select round(months_between(sysdate,to_date('10.07.2020'))/12) from dual;TRUNC cuts the fraction and ROUND rounds it. For example it would be a difference for -8.7.
Edited by: hm on 21.03.2012 02:42 -
I've calculated it myself and get different results.
FUNCTION calc_customer_profit (p_custid in number)
RETURN NUMBER
IS
v_days number default 0;
v_profit number default 0;
cursor c_profitvalues is
select ren.customer_id
, ren.rent_dt
, ren.return_dt
, ren.daily_rate
from rentals ren
where ren.customer_id = p_custid
order by ren.customer_id;
BEGIN
for r_profitvalues in c_profitvalues loop
v_days := Days_Between(r_profitvalues.rent_dt, r_profitvalues.return_dt);
v_profit := (v_days*r_profitvalues.daily_rate)+v_profit;
end loop;
return v_profit;
END calc_customer_profit;How about this:
SQL> create or replace
2 FUNCTION Days_Between (first_dt IN DATE, second_dt IN DATE := sysdate) RETURN NUMBER
3 IS
4 BEGIN
5 RETURN TO_NUMBER(TO_CHAR(second_dt, 'J')) - TO_NUMBER(TO_CHAR(first_dt , 'J'));
6 END;
7 /
Function created.
SQL>
SQL> set null {null}
SQL>
SQL> select dt1, dt2, Days_Between(dt1, dt2)
2 from (
3 select to_date('24.12.2004', 'DD.MM.YYYY') dt1, to_date('01.01.2005', 'DD.MM.YYYY') dt2 from dual
4 union all
5 select to_date('01.01.2005', 'DD.MM.YYYY') dt1, to_date('08.01.2005', 'DD.MM.YYYY') dt2 from dual
6 union all
7 select to_date('01.01.2005', 'DD.MM.YYYY') dt1, to_date('01.01.2005', 'DD.MM.YYYY') dt2 from dual
8 union all
9 select to_date(NULL, 'DD.MM.YYYY') dt1, to_date('01.01.2005', 'DD.MM.YYYY') dt2 from dual
10 union all
11 select to_date('01.01.2005', 'DD.MM.YYYY') dt1, to_date(NULL, 'DD.MM.YYYY') dt2 from dual
12 );
DT1 DT2 DAYS_BETWEEN(DT1,DT2)
24-DEC-04 01-JAN-05 8
01-JAN-05 08-JAN-05 7
01-JAN-05 01-JAN-05 0
{null} 01-JAN-05 {null}
01-JAN-05 {null} {null}
SQL>
Maybe you are looking for
-
Having had some photos done at a photographers, they have passed me the disc of the slideshow, which is in avi format, however I cannot view it on my imac, I would be really grateful if someone could advise me what software I need to download that is
-
Text Caption Dialog window is black-help!
For some reason, the text caption dialog box window is black. It did not used to be black, but somehow decided it wanted to be black now. This makes is incredibly difficult to view the black text as I attempt to edit it. Anyone else have this problem
-
Open Process Orders take-over when going-live
Hello PP People Does anyone have any experience/recommendation about the transition/take-over of open process orders from a legacy system to SAP when going live ? These process orders are started in the legacy system and should arrive in a partially
-
Setting session state post-authentication
Hi all, This application uses DATABASE ACCOUNT authentication, and has a post-authentication process that sets a few application items using code such as apex_util.set_session_state('F_MY_ITEM', v_my_value);These items are used to secure certain tab
-
Generated Report using two rows for headers
I have generated an .rpt report to be emailed and turned into an excel spreadsheet. The problem I have encountered is the characters in the header were cutting off at about 8-9 characters. I have correct this but now all the characters in the header