How to get the difference between two columns in a column group
Hi All,
My first time here and really new to programming. I would like to get the difference between 2 columns that are inside
a column group.
Here is my sample table below: The Column Group is PeriodNumber and can only choose 2. like 1 and 2.. I would like to have a third row which will simply calculate the difference between the amounts in PeriodNumber 1 and 2.
PeriodNumber
Account 1 2
1) Cash 10,000 15,000
2) Receivables 12,000 11,500
3) Equipment 5,000 5,500
Total Assets 27,000 32,000
Hi yabgestopa,
From your description, you want to get the difference between two columns in a column group. After testing it in my environment, we can use custom code to achieve your requirement. For more details, you can refer to the following steps:
Copy the custom code below and paste it to your report. (Right-click report>Report Properties>Code)
Dim Shared Num1 As Integer
Dim shared Num2 As Integer
Public Function GetAmount(Amount as Integer, Type as String)
If Type = "1" Then
Num1=Amount
Else
Num2=Amount
End If
Return Amount
End Function
Public Function GetDif()
Return Num1-Num2
End function
Right-click the second column to insert a third column with Outside Group-Right.
Then use the expressions below in the matrix.
=Code.GetAmount(Fields!Amount.Value,Fields!PeriodNumber.Value)
=code.GetAmount(Sum(Fields!Amount.Value),Fields!PeriodNumber.Value)
=Code.GetDif()
The report looks like below.
If you have any questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Similar Messages
-
How to get the difference between two HashMaps
i have two HashMaps
HashMap first = new HashMap<Integer,Object>();
HashMap second = new HashMap<Integer,Object>();
How to get the difference between one and two and put the result in the third
HashMap third = new HashMap<Integer,Object>();My bad, difference of course means removeAll():Map<Integer,Object> first = new HashMap<Integer,Object>();
Map<Integer,Object> second = new HashMap<Integer,Object>();
Map<Integer,Object> third = new HashMap<Integer, Object>(first);
third.keySet().removeAll(second.keySet());No loops needed. -
How to get the difference between two date
Hello,
I want to know how to write a code the tell me the difference between two date, I am using
oracle.jbo.domain.Date
i have a rent date and return date so my code is
Date rent=(Date)nr.getAttrbute("RentDate"),ret=(Date)nr.getAttrbute("ReturnDate");
is there a way to know the difference in days between those two dates ?
Thankshi,
try this.....
DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy");
Date date = (Date)formatter.parse(dateStr); //// dateStr <- from date value (that is string value)
Date dateto = (Date)formatter.parse(datetostr); //// datetostr <- to date value (to date getting from as a string)
Calendar cal = Calendar.getInstance();
cal.setTime(date);
Calendar calto = Calendar.getInstance();
calto.setTime(dateto);
fromDate = cal.get(Calendar.DATE) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR);
toDate = calto.get(Calendar.DATE) + "/" + (calto.get(Calendar.MONTH) + 1) + "/" + calto.get(Calendar.YEAR);
// System.out.println("from Date : " + fromDate);
if ((fromDate != null && toDate != null) && (date.compareTo(dateto) > -1) ) {
fc.addMessage("VacationQueryComponent", new FacesMessage(FacesMessage.SEVERITY_ERROR, "From Date cannot be lower than To Date", "From Date cannot be lower than To Date"));
fc.renderResponse();
thks. -
How to get the difference between two BufferedImages?
All the BufferedImage which is grabbed from AWT may be same each other,
i only want to get the different part of two continuous BufferedImages and send ti over internet.
I have compared two BufferedImages by RGB (int[]), but this process wastes 400~500ms,it's terrible,:)
who has any good idea about this?
thanks
Best Wishes
mauvespanthanks ! cary ,
I have a list contained some BufferedImages gotten from AWT component,and then these images
will be transfered to client and displayed in Internet explore ,actually there are only some difference
between two continuous BufferedImages,i don't want to transfer the WHOLE image to client,SO i
want to handler every image before sending to client , at last, the different part will only be sent to client.
All these ideas will be contained this method:
* Compare the specified two BufferedImages and return the different part between them.
* @param ref the specified first image
* @param gen the specified sencond image
* @return the different part between the specified two images.
public static void BufferedImage compareBufferedImage(BufferedImage ref,BufferedImage gen){
to finish this method ,do you have any good ideas?or sample code?
thanks
Best wishes
mauvespan -
How to get the difference between two dates???
HI I have two dates and I want to test if there is an hour between them.
Is there a way to compare two dates like mySQL can with dateDiff(date1,date2);
Thanks alot.
GrahamThis link is now out of date as they have revamped the structure. Yep. Here it is again: http://forum.java.sun.com/thread.jsp?forum=31&thread=502686
I've also noticed that my comment regarding daylight saving was misleading. The demonstrated method for calculating difference between Dates is reliable. However, one needs to be careful when interpreting Dates in a daylight saving timezone. -
Java code to get the difference between two dates in days
Hi ppl,
I need to write a user defined function to get the difference between two date nodes, in days.Please help me out
regards,
PrashanthHi,
have a look at those two:
(How do I calculate the difference between two dates?)
http://joda-time.sourceforge.net/faq.html
Calculating the Difference Between Two Datetime Stamps
http://www.xmission.com/~goodhill/dates/deltaDates.html
Get difference in days
http://javaalmanac.com/egs/java.util/CompDates.html
Regards,
michal -
How to get the difference of two dates in years,months and days
Hi friends,
how to get the difference of two dates in years,months and days
for ex 2 years 3 months 13 days
select (sysdate-date_Start) from per_periods_of_service
thanksSomething like this...
SQL> ed
Wrote file afiedt.buf
1 with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
2 select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
3 select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
4 )
5 -- end of test data
6 select c_start_date, c_end_date
7 ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
8 ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
9 ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
10* from t
SQL> /
C_START_D C_END_DAT YRS MNTHS DYS
17-NOV-06 21-JAN-08 1 2 4
21-NOV-06 17-FEB-08 1 2 27
21-JUN-06 17-JUL-08 2 0 26
SQL>But, don't forget that different months have different numbers of days, and leap years can effect it too. -
How to get the difference between these two dates
Hello Friends,
I need to get the difference between these two fields which store dates but with varchar2 data types
SELECT pac.segment1, pac.segment2 emp_no, pac.segment3 NAME,
pac.segment4 POSITION, pac.segment5 start_date, pac.segment6,
pac.segment7
FROM per_analysis_criteria pac, fnd_id_flex_structures_vl ffs
WHERE ffs.id_flex_structure_code = 'Employee Rejoin'
AND ffs.id_flex_num = pac.id_flex_num
AND TO_CHAR (TO_DATE (pac.segment7, 'YYYY/MM/DD HH24:MI:SS'))
- TO_CHAR (TO_DATE (pac.segment6, 'YYYY/MM/DD HH24:MI:SS')) > 1;
my query is something like this...
am trying to find the difference between the last two columns but with not much luck..
can some one suggest me a solution pleaseSELECT pac.segment1, pac.segment2 person_id, pac.segment3 NAME,
papf.employee_number, paaf.supervisor_id, pac.segment4 POSITION,
pac.segment5 start_date, pac.segment6, pac.segment7,
papf2.email_address,
( TO_DATE (TO_CHAR (pac.segment7), 'DD-MON-YYYY HH:MI:SS AM')
- TO_DATE (pac.segment6, 'DD-MON-YYYY HH:MI:SS AM')
+ 1
) difference,
POST.email_address
FROM per_analysis_criteria pac,
apps.fnd_id_flex_structures_vl ffs,
per_all_people_f papf,
per_all_assignments_f paaf,
per_all_people_f papf2,
(SELECT email_address, person_id
FROM per_all_people_f
WHERE person_id IN (
SELECT person_id
FROM per_all_assignments_f
WHERE position_id IN (SELECT position_id
FROM per_positions
WHERE NAME LIKE 'HR Manager.704.')
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date)
AND TRUNC (SYSDATE) BETWEEN effective_start_date AND effective_end_date
AND business_group_id = fnd_profile.VALUE ('PER_BUSINESS_GROUP_ID')) POST
WHERE ffs.id_flex_structure_code = 'Employee Rejoin'
AND TO_CHAR (papf.person_id) = pac.segment2
AND ffs.id_flex_num = pac.id_flex_num
AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date
AND papf.effective_end_date
AND papf.current_employee_flag = 'Y'
AND papf.person_id = paaf.person_id
AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date
AND paaf.effective_end_date
AND papf.person_id = paaf.person_id
AND papf2.person_id = paaf.supervisor_id
AND paaf.primary_flag = 'Y'
AND TRUNC (SYSDATE) BETWEEN papf2.effective_start_date
AND papf2.effective_end_date
AND papf2.current_employee_flag = 'Y'
and ( TO_DATE(to_char(pac.segment7), 'DD-MON-YYYY HH:MI:SS AM')-TO_DATE (pac.segment6, 'DD-MON-YYYY HH:MI:SS AM')+1) >1
last line is giving me the error pls suggest a solution -
Trying to Get the "Difference" Between Two Tracks
What I am trying to accomplish is this: I have an audio track of a voiceover with a music bed beneath it. I also have the bed music by itsself, without the voiceover. I want only the voice portion. Is there a way that I can "cancel out" the music portion or get the difference between the two tracks (just the voice portion)? It seems that there should be some means of doing this, but for the life of me I cannot figure out how to do it!
Any advice?If it's exactly the same music track, then as long as you line it up sample-accurate and the levels co-incide, you can do a simple subtractive process. You need both files available, trimmed to length. Open them both in Edit View, and copy one of them to the clipboard. Open the other, and select Mix-paste, and use the 'invert' option. That will effectively subtract one from the other, with the difference being your vocal.
Have to tell you though that the chances of getting this spot on are amazingly low... any errors at all leave you with bleed-through, about which you can do nothing. -
How to get the difference of two dates?
let's say i have a table named tblData and has 4 columns: data_RefNo, data_DateReported, data_TargetDate, data_Data
tblData returns 2 rows.
data_RefNo.............data_DateReported.............data_TargetDate........................data_Data
10000................10-20-2004 10:55:44 AM........10-20-2004 10:57:44 AM........Slow Response Time
10000................10-21-2004 10:55:44 AM........10-21-2004 11:55:44 AM........Bug Error
i just wana ask how to get the difference of the date_DateReported and date_TargetDate.
i tried this code but it didnot work
public Vector get_con_pf()
Vector vData = new Vector();
String query = "SELECT * FROM tblData WHERE data_RefNo= '"'10000'"'";
try
DBConnect db = new DBConnect();
db.openCon();
ResultSet rs = db.execute(query);
while (rs.next())
vData.addElement(DATEDIFF(mi, rs.getString("st_DateReported"), rs.getString("st_TargetFinishDate")));
db.closeCon();
catch (Exception e)
System.out.println("Error: " + e );
return vData;
i want to return the difference of the data_DateReported and date_TargetDate, i did this
vData.addElement(DATEDIFF(mi, rs.getString("st_DateReported"), rs.getString("st_TargetFinishDate")));but it didnot work.
How do i get that? because i want to return a vector.
the code must return the values:
2 for the 1st rows because the difference is only 2 minutes, and
60 for the 2nd row.ooops i tried this one:
query = "SELECT *, DATEDIFF(mi, data_DateReported, data_TargetDate) AS diff FROM tblData WHERE data_RefNo = '10000'";and it works.
hehehehe!!!!!!
problem solved! :) -
Need to get the difference between two period
Hi All,
I need to get the difference of two posting period like period is in format YYYYMM.
I need to subtract posting perid '200512' FROM '200601' how will be it possible.
Please suggest.
Thanks,
SandyHi,
YOu can also do like the following.
Determine you first day of first period and last day of second period.
data: first_day type datum,
last_day type datum,
days type i.
first_day = date from FM RKE_GET_FIRST_DAY_IN_PERIOD
last_day = date from FM RKE_GET_LAST_DAY_IN_PERIOD
days = last_day-first_day.
Thanks,
Ramakrishna -
Function Module to get the difference between two times.
Hi All,
I want to know if there is any function module that gives me the difference between two specified times.
For Ex: Time 1: 12/01/2007 00:01 A.M
Time 2: Time 1 - 180 Seconds. This changes the time, also may even change the Date. (As in above situation, the Time 2 will be 11/30/2007 11:58 P.M)
Could some one please suggest if there is any function module for this case.
Thanks in Advance.Hi, You can use the following function module to calculate the diffrence between to dates in the unit that you want.
COPF_DETERMINE_DURATION calculates the difference between two dates and time in minutes and hours.
Parameters:
EXPORTING
I_START_DATE "The start date of the time interval
I_START_TIME "The start time of the time interval
I_END_DATE "The end date of the time interval
I_END_TIME "The end time of the time interval
I_UNIT_OF_DURATION "Time unit of the duration if not to be calculated in days.
Value ===== Meaning
' ' ===== Day (default)
D ===== Days
H ===== Hours
MIN ===== Minutes
MON ===== Months
S ===== Seconds
WK ===== Weeks
YR ===== Years
I_FACTORY_CALENDER "A factory calender if not using the Gregorian calender
IMPORTING
E_DURATION "Time difference in unit specified.
Message was edited by:
Rajesh Soman -
How to get percentage difference between two matrices?
Good day everyone, I just want to ask how to get the percentage difference between two binary matrices. This is for comparing two images converted to matrices in LabView. Thank you.
Solved!
Go to Solution.pinkman wrote:
Good day everyone, I just want to ask how to get the percentage difference between two binary matrices. This is for comparing two images converted to matrices in LabView. Thank you.
You probably converted it to a 2D array (A matrix in LabVIEW has a special meaning).
"Binary" is not very well defined (unless you are looking for the number of bits that are different). What is the datatype? Was it a color image or a greyscale image? Are both arrays the same size?
How do you define "percentage difference"? Which one of the two is the 100% reference?
Do you want a new 2D array where each element is the difference of the second array compared to the first (or vice versa), expressed in percentages?
Do you want to know what percentage of array elements are different between the two arrays?
Do you want to know the average difference between all array elements?
All possible interpretations can be easily solved with very little code, but you need to explain in more detail what you actually want?
Here is a simple solution for case #2, for example (assuming the array have the same size, and we only want a rought estimate, rounded down to the nearest integer percent):
LabVIEW Champion . Do more with less code and in less time .
Attachments:
PCT-Difference.png 16 KB -
I have a database table where it keeps record of the transaction when it starts at StartTime and when it ends at EndTime. Both these entries are having the timestamp entries. Say for example, I have a tuple with Entries like 'Transaction A' starts at '2014-05-07
20:55:03.170' and ends at '2014-05-08 08:56:03.170'. I need to find the difference between these two timestamps and my expected output is 12:01:00.000. Let me know how to achieve this ?Hi,
You can use below script which calculates difference as DD:HH:MM:SS. You can modify the same:
DECLARE @startTime DATETIME
DECLARE @endTime DATETIME
SET @startTime = '2013-11-05 12:20:35'
SET @endTime = '2013-11-10 01:22:30'
SELECT [DD:HH:MM:SS] =
CAST((DATEDIFF(HOUR, @startTime, @endTime) / 24) AS VARCHAR)
+ ':' +
CAST((DATEDIFF(HOUR, @startTime, @endTime) % 24) AS VARCHAR)
+ ':' +
CASE WHEN DATEPART(SECOND, @endTime) >= DATEPART(SECOND, @startTime)
THEN CAST((DATEDIFF(MINUTE, @startTime, @endTime) % 60) AS VARCHAR)
ELSE
CAST((DATEDIFF(MINUTE, DATEADD(MINUTE, -1, @endTime), @endTime) % 60)
AS VARCHAR)
END
+ ':' + CAST((DATEDIFF(SECOND, @startTime, @endTime) % 60) AS VARCHAR),
[StringFormat] =
CAST((DATEDIFF(HOUR , @startTime, @endTime) / 24) AS VARCHAR) +
' Days ' +
CAST((DATEDIFF(HOUR , @startTime, @endTime) % 24) AS VARCHAR) +
' Hours ' +
CASE WHEN DATEPART(SECOND, @endTime) >= DATEPART(SECOND, @startTime)
THEN CAST((DATEDIFF(MINUTE, @startTime, @endTime) % 60) AS VARCHAR)
ELSE
CAST((DATEDIFF(MINUTE, DATEADD(MINUTE, -1, @endTime), @endTime) % 60)
AS VARCHAR)
END +
' Minutes ' +
CAST((DATEDIFF(SECOND, @startTime, @endTime) % 60) AS VARCHAR) +
' Seconds '
Reference:
http://sqlandme.com/2013/12/23/sql-server-calculating-elapsed-time-from-datetime/
- Vishal
SqlAndMe.com -
How to get the diff between two dates - # of days
Hi Experts,
I have requirement to know the difference between dates. In my presentation layer two columns as created date and updated date. I want to know the difference in # of days in the presentation services.
Please provide some pointers.
Thanks in adv
svrHi,
In the presentation layer you can create a column with a custom formula of this:
TIMESTAMPDIFF(SQL_TSI_DAY, datecolumn1,datecolumn2)
The result shown in the column will be the difference in days between the two dates.
Regards,
Matt
Maybe you are looking for
-
SAP B1 + NFe. Erro: O documento XML não está em conformidade com o esquema.
Olá pessoal, Estou fazendo testes com a Nf-e do SAP B1 9.0 PL 11. Segui o documento How to Work with SAP Nota Fiscal Eletrônica in SAP Business One.pdf, e fiz todas as configurações necessárias. Inclui um certificado digital, e estou realizando teste
-
I cant load some web pages from safari?
My Mac has over the last 24 hrs become very slow! It will load some pages but not others. I can access my email on Hotmail but not google or apple etc? When I click on safari the apple address comes up but the page doesn't load the blue bar is hal
-
WL 5.1/SP11 mod_wl_ssl.so doesn't work on Linux 7.1
Did anyone experience WL 5.1/SP11 mod_wl_ssl.so working on Apache 1.3.22 or 1.3.19 on Linux 7.1? The same environment setup works with sp8 mod_wl_ssl.so. Brian
-
Dear All, I am using my own MenuItemUI to render the disabled foreground for html text present in the Menu Item. So, in my CustomMenuUI, i am overriding the paint() method to obtain the disabled foreground when the Menu Item is disabled. But every th
-
Switch por-security - - - Security Violation Count
I have some question with a device cisco 3400 metroaccess. In a interface i have this config. 3400_METROACESS#sh run int g0/1 Building configuration... Current configuration : 449 bytes interface GigabitEthernet0/1 description switchport access vla