Date difference calculation help needed
Hi,
I have a form with a date field and one text field which is hidden..in case the date field value is less than the current date minus 3 years then the text field should display else not. Please advice what logic/code can be used.
Any suggestions would be highly appreciated !!
Thanks
Kapil
In the mean time, a couple of stylisitc suggestions:
if(start.getTime().before(end.getTime()) == true)
// == true is redundant and cluttersome
if(start.getTime().before(end.getTime()))
Long L = new Long(diff);
return L.intValue();I'd suggest returning a long, rather than an int. If you insist on returning an int, because you're sure that the number of days will never be more than Integer.MAX_VALUE, then add an assertion that its not.
assert diff <= Integer.MAX_VALUE : diff + " too big";The Long is overkill. If you do have a small enough value, just do return (int)diff;
Similar Messages
-
Date difference calculation - help!
hey people, i've got the below method, i'm trying to calculate the difference between two dates. the calculation is wrong as it is outputing the wrong duration... can anyone help?
public int getDuration(Date startDate,Date endDate)
GregorianCalendar start = new GregorianCalendar();
start.setTime(startDate);
GregorianCalendar end = new GregorianCalendar();
start.setTime(endDate);
long diff = 0L;
if(start.getTime().before(end.getTime()) == true)
diff = end.getTimeInMillis() - start.getTimeInMillis();
diff = diff/(24*60*60*1000);
Long L = new Long(diff);
return L.intValue();
THanks, IanIn the mean time, a couple of stylisitc suggestions:
if(start.getTime().before(end.getTime()) == true)
// == true is redundant and cluttersome
if(start.getTime().before(end.getTime()))
Long L = new Long(diff);
return L.intValue();I'd suggest returning a long, rather than an int. If you insist on returning an int, because you're sure that the number of days will never be more than Integer.MAX_VALUE, then add an assertion that its not.
assert diff <= Integer.MAX_VALUE : diff + " too big";The Long is overkill. If you do have a small enough value, just do return (int)diff; -
Hello Everyone,
We need to calculate a day difference between two days. There is many suggestions about using the following approach:
(date1.getTime() - date2.getTime())/86400000.
This seems to work until we hit a Daylight Savings Time issue and nobody seems to talk about that. When in April, for example, we get 1 hour less then the result of the calculation above will not be the whole number. Well, we can use Math.ceil() function for that. Then, in October, we get 1 hour back so now we have to use Math.floor() function to get the right result.
Does anybody have any idea as to when to use one or another. I was thinking of using modulus division. If the result is not equal to zero then we have to apply one of those functions. The question now is, how to identify which function to apply? Or is there any other, less cumbersome way to properly get day difference between two dates?
Any help will be greatly appreciated.
Thanks,
YouriiI think i figured out how to calculate the difference in days with Daylight Savings Time changes. Here is the code:
* This method returns difference in days between two Dates passed in.
* It identifies Daylight Savings Time changes and automatically
* adds or substracts one hour when needed ...
private int dayDifference(java.util.Date date1, java.util.Date date2) {
final long M_SECS_PER_DAY = 24*60*60*1000;
final long M_SECS_PER_HOUR = 60*60*1000;
long days = (date1.getTime() - date2.getTime());
if (days%M_SECS_PER_DAY != 0) {
if ((days + M_SECS_PER_HOUR)%M_SECS_PER_DAY == 0) {
System.out.println("Adding one hour ...");
days += M_SECS_PER_HOUR;
} else {
System.out.println("Substracting one hour ...");
days -= M_SECS_PER_HOUR;
} else {
System.out.println("No alterations made ...");
return (int)(days / M_SECS_PER_DAY);
Let me know what you think ... -
Date Difference Calculation in BW3.5
Hi
We are calculating date differences between 2 dates i.e. Delivery Date - System Date.For System date we used variable exit to derive the value.But when we create CKF on Delivery Date,we necessary have to keep date field in Drilldown(in rows).But reports needs to give Overview while including date field in rows removes the granularity.
Is thier any other way we can handle this situation.
Regards
PraveenYou have to put ur delivery date in Rows if u r doing the Formula variable with replacement path. There is no option.
Khaja -
Date Difference Calculation in BSO Cube
Hello,
need help with Date Calc
I have a Dim. Called Inv Date and another Dim. Check Date( which is Time Dim.)
I will like to do this calculation Inv Date - Check date and store the difference in a Measure member called days outstanding
This should return how many days difference between both dates.
will really appriciate if some one could help.
thkx
mits
Edited by: user12527998 on Jan 28, 2010 1:43 PMHi,
I always find a post by John Booth's a useful guidance when you are wanting to run calculations with dates, have a read at :- Calculations with dates
If you are using Version 11 you also have a look at the new date functions e.g. @DATEDIFF - http://download.oracle.com/docs/cd/E12825_01/epm.111/esb_techref/calc_datediff.htm
Cheers
John
http://john-goodwin.blogspot.com/ -
Here is the situation:
I am doing a quick "play around" between Pages/Word, Numbers/Excel and Keynote/Powerpoint.
This is to refresh my memory to windows, since I am going into a short-term (5 - 7 or 8 years) of IT.
I need help with calculating the average time of sunrise for one week, using two sheets.
The times given are 5:40am, 5:41am, ........ 5:46am. The cells: B5 - B11 (Sunrise Column for week 1). The name for this sheet is "Weekly".
The equation is going to be place in cell B5 of sheet named "Monthly" representing the average time of sunrise for that week.
In excell, I understand "Weekly!B3" refers to cell B3 on worksheet "Weekly".
How would I do this in numbers? (I will figure out how to do it in Excell.)
Thanks again guys (and ladies)!In fact, the problem is not the one which you described.
The way to reference a cell or a range of cell is perfectly described in iWork Formula and Functions User Guide in which every user may get it.
The important thing to know is that in NumbersLand, 5:40am isn't a time value but a date_time one.
In the tables above, I deliberately choose to insert time values entered at different dates so, the formula inserted in Monthly :: B5
=AVERAGE(Weekly :: B5:B11)
return an exact result which doesn't match what we are wanting to get.
This is why I used the auxiliary column C
In Weekly :: C5, the formula is :
=TIMEVALUE(B)
Apply Fill Down to insert the formula in rows below.
The formula returns the time value using the unit day.
In Monthly // C5, the formula is :
=AVERAGE(Weekly :: C5:C11)
but I guess that you don't wish to get the result in this format.
In Monthly // D5, the formula is :
=DURATION(0,AVERAGE(Weekly :: C5:C11))
You may edit the format of this duration cell as you want.
An alternate formula would be :
=TIME(,AVERAGE(Weekly :: C5:C11)*24*60,)
But CAUTION, one more time, as you may see, the cell will contain a date component.
Yvan KOENIG (VALLAURIS, France) vendredi 27 mai 2011 12:20:15
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer ! -
REPORT CALCULATION HELP NEEDED!!!
Hello
I have a report where i need to do some calculation .
I have 3 columns in my report Businesstype , Business Code & Fact . When i display the report i see the Business Code 1 - Business Code 5 in 5 rows . But sometimes the report contains Business Code 6 along with Business Code 1 - Business Code 5 then Business Code 6 needs to calculate SUM(Business Code 1-6) and display in one row .
Could anybody please leave me any suggestions .Hi there,
Create a table
- On the first row create for each group to populate the data for Business Code [1-n] with a second column containing numeric values.
- On the second row use the sum function using current-group() function for the value that you want to calculate the sum for.
Hope this helps.
Let me how you get on.
cheers... -
Hi,
Can someone tell me what maximum values can I set in the following properties under Connection Attributes when I define a DataSource on
Application Server. I have almost 25+ web application deployed on my 10.1.2.0.2 server that all uses one data source I have defined. Now the issue is the number of requests
are very high and every now and then I get timeout error when trying to get the database connection. At one particular instance at peak time I may get over 200+ requests that
do some databse connections etc. Following are my current settings. But need to increase some more but wondering what are the maximum values I can have. I have only one server 10.1.2.0.2
Connection Retry Interval (seconds) = 5
Max Connection Attempts = 3
Cached Connection Inactivity Timeout (seconds) = 30
Maximum Open Connections = 60
Minimum Open Connections = 10
Wait For Free Connection Timeout (seconds) = 15
What other properties can I have to make use of datasource effectively.
ThanksHere is the copy of my datasources.xml.
<?xml version = '1.0' standalone = 'yes'?>
<!DOCTYPE data-sources PUBLIC "Orion data-sources" "http://xmlns.oracle.com/ias/dtds/data-sources-9_04.dtd">
<data-sources>
<!--
An example/default DataSource that uses
Oracle JDBC-driver to create the connections.
This tag creates all the needed kinds
of data-sources, transactional, pooled and EJB-aware sources.
The source generally used in application code is the "EJB"
one - it provides transactional safety and connection
pooling. Oracle thin driver could be used as well,
like below.
url="jdbc:oracle:thin:@host:port:sid"
-->
<data-source class="com.evermind.sql.DriverManagerDataSource" name="OracleDS"
location="jdbc/OracleCoreDS" xa-location="jdbc/xa/OracleXADS"
ejb-location="jdbc/OracleDS"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="scott" password="tiger"
url="jdbc:oracle:thin:@//localhost:1521/oracle.regress.rdbms.dev.us.oracle.com"
inactivity-timeout="30"/>
<!-- For SQL Server -->
<data-source location="jdbc/TestDS"
class="com.microsoft.jdbcx.sqlserver.SQLServerDataSource"
password="pwd" xa-location="jdbc/TestDS"
ejb-location="jdbc/TestDS"
connection-driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
username="usr"
url="jdbc:microsoft:sqlserver://someloc99:1433/DevelopmentAp"
inactivity-timeout="30" name="jdbc/TestDS"
connection-retry-interval="5" max-connections="50"
max-connect-attempts="3">
<description>jdbc/TestDS</description>
<property name="DatabaseName" value="DevelopmentAp"/>
<property name="serverName" value="someloc99"/>
</data-source>
</data-sources>I also tried changing max-connections="0" it did helped but still after sometime I get timeout while connecting to the database. Don't know if it's with SQL Server that is not letting that many concurrent connections/sessions or something on the Application Server side.
Thanks
Message was edited by:
WhiteSox
Message was edited by:
WhiteSox -
PDF form field calculation help needed
I need to make some simple calculations on a pdf form and need some help.
I have a form field for number of guests.
A field for a set cost for various tickets (there are 3 levels of ticket prices) (I might not need this field).
A subtotal of the guests attending and ticket price.
A grand total of the subtotals.
I can't figure out how to either put in a fixed cost in a form field or input a calculation so that the number of tickets is muliplied by a fixed number and gives me a subtotal.
Thanks.Ok. I finally got the calculations to work. But..... when I save and open in Reader, they don't work. Go back to Pro, they don't work there now either. They also don't show up under the Set Field Order Calculations. To reset them, i have to erase the calculations, save, redo the calculations. Preview the form and everything works — calculations happen and i get a total.
Adobe Reader usage rights are enabled.
Why is this so hard?
I found this thread http://forums.adobe.com/message/1152890#1152890 about it. Is this bug still going on since 2009?
Ok. Apparently you have to enable reader rights after the form is done. It seems to work now. What a pain. -
Date difference calculation with user input variable
Hi,
I have the following requirement in BEx:
The user inputs a date value and I have to calculate the difference between the date entered by the user with the Due Date in the cube, to determine the number of backlog days. Basically, I need to calculate Past Due in number of days. I need to display the Amount due for the Time buckets like 1 -10 days, 11 -30 days.
The report output has to be in the format below:
Columns:
1 u2013 10 days Past Due $100.00
11 u2013 30 days Past Due $15.00
Rows:
Customer#
The cube has data from Jan 2005 to June 2008.
For Eg: User Input Date = 04/30/2008.
It should compare the input date to the due date for each record in the cube.
Any suggestions are appreciated.Hi Kumar,
We have developed simar reports in our previous projects.
You need to follow the following steps.
1. Create a new restricted key figure globally on Past Due $100. Restriction details I will let you know in the ensuing steps.
2. Create another restricted key figure globally on Past Due $15. Restriction details I will let you know in the ensuing steps.
3. Create a Z varuable on Calday and offset it -1 (use the button next to exclude button).
4.Create another Z varuable on Calday and offset it -10 (use the button next to exclude button).
5. Create another Z varuable on Calday and offset it -11 (use the button next to exclude button).
6. Create another Z varuable on Calday and offset it -30(use the button next to exclude button).
7 Restrict the RKF past due 100$ (defined in sl 1)between the variable range defined in 3 and 4.
8. Restrict the RKF past due 15$ (defined in sl 2) between the variable range defined in 5 and 6
Now drag and drop those two RKF to column and you will get the desired result in C1 and C2 as follows:
Columns:
C1 :1 u2013 10 days Past Due $100.00
C2 :11 u2013 30 days Past Due $15.00
If the above info serves your purpose, please reward me with the point.
Regards,
Subha -
Very simple calculation help needed.
I am a non-techie person being tasked with creating a form. Java? Thats coffee right?
see what I mean .
Anyway I need to have a form calculate the difference between two dollar amounts.
They are: Previous Check Amount ____________
Current Check Amount __________
Difference(+/-) _____________
I looked at doing the calculation via the value field on the calculate tab. But I see I cannot do that unless I choose the Custom Calculation Script and writing it myself. I am not sure how to do that. If I could send cookies to my savior I would.
Thanks!!Gilad,
Thanks for the reply,
The fields are "Previous Check Amount" and "Current Check Amount" and I need to calculate whatever (+/-) difference there would be between the two...... -
Date Difference Calculation problem
I am creating a form which should calculate the number of days between two calender dat
es using the Date2Sum expression but my result cell gives me
zeo despite setting the locale and the calculation correcttly. Where could
my problem be?
Darlington SakwaValidate the date patterns on the date fields match the date patterns used in Date2Num. For example, the attached has a start date with the display date pattern date{YYYY-MM-DD} and that matches the date pattern in my Date2Num function call.
// form1.page1.startDateNum::calculate - (FormCalc, client)
if (form1.page1.startDate.isNull) then
$.rawValue = ""
else
$.rawValue = Date2Num(form1.page1.startDate.rawValue,"YYYY-MM-DD")
endif
Steve -
Data Load scenario- help needed
Hi gurus,
Please help me with the below scenarios for the LO mechanism:
Rec 1 entered in R3 between T1 and T2 (during R3 setup table population). When does Rec1 get into BW?
Rec 2 entered in R3 between T2 and T3 (after setup table population but before initialization loads). When does Rec 2 get into BW?
Rec 3 entered in R3 between T3 and T4 (during initial loads in BW). When does Rec 3 get into BW?
Rec 4 entered in R3 after initialization is completed after T4. When does Rec 4 get into BW?
Time
T1 T2 T3 T4
|--|---||--
Rec 1 Rec2 Rec 3 Rec 4
T1 T2 Setup Tables populated
T3 T4 Initial Loads performed
T4 onwards Delta Loads performedHi ,
senario1;Rec 1 entered in R3 between T1 and T2 (during R3 setup table population). When does Rec1 get into BW?
during the setup table filling ,v3 jobs will be descheduled
you need to lock all the user's (no user can post documents)
Rec 2 entered in R3 between T2 and T3 (after setup table population but before initialization loads). When does Rec 2 get into BW?
here just setup table is filled,however init is not performed
so still v3 jobs will be in descheduled mode ,the posting which were/are happened sits in application tables
Rec 3 entered in R3 between T3 and T4 (during initial loads in BW). When does Rec 3 get into BW
here init is running,it will be down time for R/3 due to heavy load processing to BW
so still v3 jobs will be in descheduled mode ,the posting which were/are happened still sits in application tables
Rec 4 entered in R3 after initialization is completed after T4. When does Rec 4 get into BW?
after init,now we need to schedule v3 jobs, so all the postings(which were posted earlier/which are posted for the moment) now will transfer from application tables to delta que depending on the update mode(direct/queued/un serialized)
Hope this helps you!!!!!!!
cheers,
Swapna.G
Message was edited by:
swapna gollakota
Message was edited by:
swapna gollakota -
ALE Data Transfer - Urgent help needed
I am trying to set up an ALE interface from a SAP ECC 6 system to another SAP ECC 6 system using HRMD_A idocs. The complication I have is in the receiving system, I need to generate a new PERNR for all employees transferred.
Can anybody advise how to go about doing this?
Many thanks
JezHi you can send the employees from sender system to reciever system.
With the help of transaction pfal you can send the personnel number.
You have to choose the ploan version 01
object type will be p
in object id write the employee number which will be transferred to the reciever system
Then push the run button.
But you have to configure HRMD_A in ALE implementation. -
Sql calculation help needed.
Hi all gurus.
I'm having problem where I need to calculate AR days.
formula is (sales of prior 3 months/90)/Ar $ amount.= Days
Data is stored in two different table.
1.Monthly data table .
CURR_MO REVENUE_PRIOR_MO (in Sept they will enter what was made/achieved in AUG)
JANUARY 0
FEBRUARY 1717631
MARCH 1591972
APRIL 1649450
MAY 1662600
JUNE 1667823
JULY 1669651
AUGUST 1709323
SEPTEMBER 2006983
2) Ar $ value enter each week in Balance sheet table
AR$ week# period
2589570
10
07-MAR-13
2376294
11
14-MAR-13
2454919
12
22-MAR-13
2767058
13
31-MAR-13
2603831
14
05-APR-13
2759590
15
11-APR-13
2376294
16
18-APR-13
2308476
17
26-APR-13
2455142
18
02-MAY-13
2498546
19
10-MAY-13
2457499
21
23-MAY-13
2461661.79
22
30-MAY-13
2310346
23
06-JUN-13
2512139
24
13-JUN-13
2267758
25
20-JUN-13
2497566
26
27-JUN-13
2583208
27
04-JUL-13
2195667
28
11-JUL-13
2288098
29
18-JUL-13
2322778
30
25-JUL-13
2306878
31
01-AUG-13
2513741
32
08-AUG-13
2350728
33
15-AUG-13
2554842
34
22-AUG-13
2664116
35
29-AUG-13
2743931
36
05-SEP-13
2501886
37
12-SEP-13
2315477
38
19-SEP-13
I want to take sum of 3 months corresponding
Daily Rev.
June
July
Aug
3-mo Total
59,844
1,669,651
1,709,323
2,006,983
5,385,957
Daily Rev.
May
June
July
3-mo Total
56,076
1,667,823
1,669,651
1,709,323
5,046,797
Daily Rev.
April
May
June
3-mo Total
55,556
1,662,600
1,667,823
1,669,651
5,000,074
Daily Rev.
March
April
May
3-mo Total
55,332
1,649,450
1,662,600
1,667,823
4,979,873
Daily Rev.
Feb.
March
April
3-mo Total
54,489
1,591,972
1,649,450
1,662,600
4,904,022
Daily Rev.
Jan
Feb.
March
3-mo Total
55,101
1,717,631
1,591,972
1,649,450
4,959,053
Highlighted daily values with be divided by Ar $ amount depending on monthly daily rev.
Output should be like (roughly this not actually output)
ARDAYS
WEEK_NUMBER
47
10
43
11
45
12
50
13
48
14
51
15
44
16
42
17
44
18
45
19
44
21
44
22
42
23
45
24
41
25
45
26
46
27
39
28
41
29
41
30
39
31
42
32
39
33
43
34
45
35
46
36
42
37
39
38I got the answer
"use the latest 3 completed months for each week"
as soon sliding window hit JUNE use june (apr-may-june)value to divide
output (coulm 1 and 2 only)
ARDAYS
WEEK#
period
AR $
47
10
3/7/2013
2589570
43
11
3/14/2013
2376294
Daily Rev.
June
July
Aug
3-mo Total
45
12
3/22/2013
2454919
59,844
1,669,651
1,709,323
2,006,983
5,385,957
50
13
3/31/2013
2767058
48
14
4/5/2013
2603831
Daily Rev.
May
June
July
3-mo Total
51
15
4/11/2013
2759590
56,076
1,667,823
1,669,651
1,709,323
5,046,797
44
16
4/18/2013
2376294
42
17
4/26/2013
2308476
Daily Rev.
April
May
June
3-mo Total
44
18
5/2/2013
2455142
55,556
1,662,600
1,667,823
1,669,651
5,000,074
45
19
5/10/2013
2498546
44
21
5/23/2013
2457499
Daily Rev.
March
April
May
3-mo Total
44
22
5/30/2013
2461662
55,332
1,649,450
1,662,600
1,667,823
4,979,873
42
23
6/6/2013
2310346
45
24
6/13/2013
2512139
Daily Rev.
Feb.
March
April
3-mo Total
41
25
6/20/2013
Maybe you are looking for
-
Calculation of interest amount with two variables formula
Hello everyone, Iu2019m facing a problem with the way that TRM calculate the interest amount for money market transaction when I have a formula with two variable, e.g. reference interest rate u201CXu201D multiplied by 0,98. Some contracts explicitly
-
Payment terms maintenance vs define terms of payment for installment.
Dear all, In Payment terms we can maintain installment payments then what is the need for Maintaining installment payments again. I am not understanding the functionality any body please explain with example. Thanks, Srini.
-
How to create a folder to store my mail?
hi, can u tell me how to create a folder to store my outgoing mails using java mail. Million Thanks for u With luv kathir
-
Obsolete error in OBIEE 10.1.3.4.1
Hi All, I need a favor from you. I'm using OBIEE 10.1.3.4.1 version. I had faced an Obsolete eror issue while creating a logical column in BMML in RPD. I tried creating a logical column with the following formula in the Expression Builder: COUNT (CAS
-
Dear All, My colleague has changed a parameter open_cursor, now if I want to verify the scope of that parameter then how can i check. scope = both scope = memory scope = spfile Is there any view or table available.? Thanks Ajay