How to Calculate AGE by getting difference between two Date Fields
HI Gems
I need to calculate AGE from getting difference from two date fields. But when i am trying to wrte fromula as Current date - date1(some date field) then it is showing error.
How can i get values.
Thanks
Manu
You already asked this question:
How to calculate AGE from two different date fields
Similar Messages
-
Calculated columns to get difference between two dates with half day
Hi,
So there is the problem I'm using a calculated column to track the number of day when an employee make a vacation request. I'm already taking weekends of the case but now I would need to be able to ask for only a half day off.
How could I perform that without taking out my first requirement?
Just in case there is my current formula:
=IF(AND((WEEKDAY([EndDate],2))<(WEEKDAY([StartDate],2)),((WEEKDAY([StartDate],2))-(WEEKDAY([EndDate],2)))>1),(((DATEDIF([StartDate],[EndDate],"D")+1))-(FLOOR((DATEDIF([StartDate],[EndDate],"D")+1)/7,1)*2)-2),
Thanks for your answers :)Hi amber,
you can simple calculate.
try this:
DATA: date1 like sy-datum,
date2 like sy-datum.
data I type i.
date1 = '20070301'.
date2 = '20070228'.
i = date1 - date2.
write: / date1, date2, i.
date1 = sy-datum.
date2 = sy-datum - 30.
i = date1 - date2.
write: / date1, date2, i.
Regards, Dieter -
Difference between Two Date Should come into Text Item
Dear All,
i want to get difference between two date into text Item :P36_C in On Change java script.
i have two Date Item :P36_A and :P36_B .i have extract these date value from table then difference comes into Text Field :P36_C.
Now i want if i change Date into Item :P36_A or Item :P36_B then Defference between two date Should Come into Item :P36_C .
So i have use Java Script Code to do this
<script>
function diffdat(){
function getVal(item){
if($x(item).value != "")
return parseFloat($x(item).value);
else
return 0;
$x('P36_C').value =
getval((TO_DATE('P36_B', 'DD-MON-YYYY'))-
getval(TO_DATE('P36_A', 'DD-MON-YYYY')))+1;
</script>
i have put this into Item HTML Form Element Attributes
onChange="javascript:diffdat();"it's not woring .
How to work that Code with dates.
ThanksYou can always create your own difference function based on your own criteria. You can modify this to suit your needs.
CREATE OR REPLACE FUNCTION CALC_OFFICE_DAYS(date1 DATE, date2 DATE)
RETURN NUMBER
IS
v_begin_date DATE := date1;
v_end_date DATE := date2;
v_office_start_time VARCHAR2(10) := '09:30 AM';
v_office_end_time VARCHAR2(10) := '06:30 PM';
v_comp_begin_time DATE;
v_comp_end_time DATE;
v_days PLS_INTEGER := 0;
v_hrs NUMBER := 0;
v_ttltm NUMBER;
BEGIN
select trunc(v_end_date) - trunc(v_begin_date)
into v_days
from dual;
select to_date(to_char(sysdate,'DD-MM-YYYY')||' '||to_char(v_begin_date,'HH24:MI'),'DD-MM-YYYY HH24:MI')
into v_comp_begin_time
from dual;
select to_date(to_char(sysdate,'DD-MM-YYYY')||' '||to_char(v_end_date,'HH24:MI'),'DD-MM-YYYY HH24:MI')
into v_comp_end_time
from dual;
select (v_comp_end_time - v_comp_begin_time)/24 into v_hrs from dual;
IF v_hrs > 4 then
v_ttltm := v_days + .5;
ELSE
v_ttltm := v_days;
END IF;
return v_ttltm;
END;
As has been noted, this question is best posted on the PL/SQL forum. -
How can get difference between 2 dates in the form of days
how can get difference between 2 dates in the form of days
Hi,
Check the following program:
REPORT ZDATEDIFF.
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
WRITE:/ 'Difference in Days ', EDAYS.
WRITE:/ 'Difference in Months ', EMONTHS.
WRITE:/ 'Difference in Years ', EYEARS.
INITIALIZATION.
FROMDATE = SY-DATUM - 60.
Regards,
Bhaskar -
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 calculate the hour difference between two dates?
hi all,
how to calculate the hour difference between two dates?
eg i trying this...
((TO_DATE(TO_CHAR(GRNi.reference_date_4,'hh24:mi'),'hh24:mi') -
TO_DATE(TO_CHAR(NVL(GRNi.reference_date_3,SYSDATE),'hh24:mi'),'hh24:mi'))*24)*60 Act_Hr
Reg.
AAKHi
To break the diff between 2 dates into days, hours, minutes, sec -- you can use the following:
select to_char( created, 'dd-mon-yyyy hh24:mi:ss' ),
trunc( sysdate-created ) "Dy",
trunc( mod( (sysdate-created)*24, 24 ) ) "Hr",
trunc( mod( (sysdate-created)*24*60, 60 ) ) "Mi",
trunc( mod( (sysdate-created)*24*60*60, 60 ) ) "Sec",
to_char( sysdate, 'dd-mon-yyyy hh24:mi:ss' ),
sysdate-created "Tdy",
(sysdate-created)*24 "Thr",
(sysdate-created)*24*60 "Tmi",
(sysdate-created)*24*60*60 "Tsec"
from all_users
where rownum < 50
HTH
RangaReddy -
Calculate the Difference Between two dates excluding weekends and Holidays
Hi,
We need to calculate the difference between the two dates by excluding the Local public holidays (It is global and varies across countries) and weekends should not be included in calculation for a business day in OBIEE.
We have two dates: Open date and close date when ever close date is null we are calculating age based on taking the current timestamp and need to exclude the weekends and Holidays when ever the close date is null.
Ex:
Col1 col2 Total
11/9/2010 2:46:38 PM Null 13
11/2/2010 8:06:26 PM 11/3/2010 5:37:03 PM 1
(In the Total we shouldn't include the weekends,holidays)
Please let me know how to calculate the difference between two dates by excluding the weekends and holidays.
Thanks
Edited by: user10441472 on Nov 22, 2010 3:14 PMYou already asked this question and I answered it...
Re: calculation of Business day in OBIEE -
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 -
I wanted to know how do you calculate the number of days between two dates
i wanted to know how do you calculate the number of days between two dates in java ? i get both the dates from the database. i guess there are many issues like leap year and Febuary having diff no of months ..etc.
thanks..
I solve my problem as
public class MyExample {
public static void main(String a[]) {
String stdate = "2009-03-01";
java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
java.sql.Date preDate = java.sql.Date.valueOf(stdate);
System.out.println(currentDate);
System.out.println(preDate);
// int dateCom = preDate.compareTo(currentDate);
// System.out.println(dateCom);
long diff = currentDate.getTime() - preDate.getTime();
int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
System.out.println(days);
} -
Calculate difference between two dates/times
Hi all,
Is there any function module to calculate difference between two dates/times which are in TIMESTAMPL format.
I need to know how many millisconde(second,minutes, hours... )there is between these two times.
Please, It is urgent
Thank you all.
Karimhi,
try the following function
CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'
EXPORTING
timestamp1 = timestamp1
timestamp2 = timestamp2
IMPORTING
difference = diff
EXCEPTIONS
OTHERS = 1.
the above function gives the difference in seconds...
try the following code to set the resolution to milliseconds..
SET RUN TIME CLOCK RESOLUTION LOW
check the thread for details:
SET RUN TIME CLOCK RESOLUTION?
all the best!!!
Regards,
Aparna -
Calculate the difference between two dates times in infopath form 2013
Hi,
I have an infopath 2013 form that contains three fields:
2 date time and the 3rd contains the difference between the two in hours
how I can make the difference between the two so that the display will be like this:
Date Time1 08/21/2014 22:00
Date Time2 08/22/2014 1:00
Diff Field 3:00Hi,
Please refer to the following article which matches your requirement exactly.
Calculate the difference between two date picker controls in InfoPath using rules and formulas - no code!
Please mark it answered, if your problem resolved. -
Calculate the difference between two dates
I would like to calculate the difference between two dates in PL/SQL and return the result as a number of days expressed as an integer value.
Denes,
A fair point, I should really have posted this on the SQL forum (I'm new to the forum as well as PL/SQL) but thanks for responding anyway. It does raise a question as to how to implement this in ApEx though.
I have created the function and am calling it as shown below from the source window of a form. The source type is 'PL/SQL expression or function' and the expression in the source window of the form is:
calc_date_difference (:p26_c_payment, :p26_c_rec)
The two parameters being passed are of type date but I'm not sure how to handle the ruturned number and populate the form in ApEx with this value.
Is it possible to do it this way or am I taking completely the wrong approach?
Regards
Sandy
This is not ApEx related but SQL related:
CREATE OR REPLACE FUNCTION calc_date_difference (
p_date_1 VARCHAR2,
p_date_2 VARCHAR2
RETURN NUMBER
v_difference NUMBER;
v_sql_err VARCHAR2 (4000);
BEGIN
v_difference := TRUNC (TO_DATE (p_date_1)) - TRUNC
(TO_DATE (p_date_2));
RETURN v_difference;
CEPTION
WHEN OTHERS
THEN
v_sql_err := SQLERRM || CHR (10) || CHR (10) ||
SQLCODE;
ND calc_date_difference;and
SQL> SELECT calc_date_difference ('23.01.2007',
'20.01.2007') diff
2 FROM DUAL;
DIFF
3
Denes Kubicek -
How to get days between two dates
Hi ,
How to get days between two dates.
Regards,
Ramesh.Hi Ramesh,
REPORT ZDATEDIFF.
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
WRITE:/ 'Difference in Days ', EDAYS.
WRITE:/ 'Difference in Months ', EMONTHS.
WRITE:/ 'Difference in Years ', EYEARS.
INITIALIZATION.
FROMDATE = SY-DATUM - 60. -
How can i get report between two dates?
Hi
how can i get report between two dates?
for example i want get reports between 20/4/2002 & 27/4/2002.
my table has date column and i can get first date( exam : .... where date:=a and/or ....i don't know this part)
thanks alot.
Regards
The Oracle Reports Team
http://otn.oracle.com/where exam_date between :from_date and :to_date
from_date and to_date are user_parameter -
Difference between two date ,according to office time.
hi,
How can I get diffrence between two date.
If I select from-date 20-03-2012 09:30AM and to-date 20-03-2012 06:30PM then output should be 1 day(as it is office time from 09:30 AM TO 06:30 PM).
ACCORDINGLY If I select from-date 20-03-2012 09:30AM and to-date 21-03-2012 02:00PM then output should be 1.5 day
select 24*(to_date(:P2_TO_DATE,'DD-MM-YYYY HH:MIPM') - to_date(:P2_FROM_DATE,'DD-MM-YYYY HH:MIPM'))"date" from dual;Hello Shirish,
WITH dates AS(
SELECT TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
,TO_DATE ('20-03-2012 06:30PM', 'DD-MM-YYYY HH:MIPM') AS end_date
FROM dual
UNION ALL
SELECT TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
,TO_DATE ('20-03-2012 04:15PM', 'DD-MM-YYYY HH:MIPM') AS end_date
FROM dual
UNION ALL
SELECT TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
,TO_DATE ('21-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
FROM dual
UNION ALL
SELECT TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
,TO_DATE ('21-03-2012 12:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
FROM dual
UNION ALL
SELECT TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
,TO_DATE ('21-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
FROM dual
UNION ALL
SELECT TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
,TO_DATE ('22-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
FROM dual
UNION ALL
SELECT TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
,TO_DATE ('22-03-2012 10:00AM', 'DD-MM-YYYY HH:MIPM') AS end_date
FROM dual
,times as(
SELECT start_date
,end_date
,TRUNC (end_date - start_date) days
,MOD (end_date - start_date,1) hours
,(start_date - 9.5/24 - TRUNC (start_date))*24 offset_start
,(end_date - 9.5/24 - TRUNC (end_date))*24 offset_end
,(end_date - 9.5/24 - TRUNC (end_date))*24
- (start_date - 9.5/24 - TRUNC (start_date))*24 offset_diff
FROM dates
SELECT TO_CHAR(start_date, 'DD-MM-YYYY HH:MIPM') AS start_date
,TO_CHAR(end_date, 'DD-MM-YYYY HH:MIPM') AS end_date
,days
,ROUND(offset_start,2) offset_start
,ROUND(offset_end,2) offset_end
,ROUND(offset_diff,2) offset_diff
,CASE WHEN offset_diff > 4 THEN
days + 1
WHEN offset_diff > 0 THEN
days + 0.5
WHEN offset_diff = 0 THEN
days
WHEN offset_diff + 9 > 4 THEN
days + 1
ELSE
days + 0.5
END computed_days
FROM timesThe first step (subquery times) computes the full days and the difference between start_date and end_date, compared to the beginning of the office ours (9.5 /24)
The second step takes the days and according to the possible values of the difference adds a half or a full day.
Regards
Marcus
Edited by: Marwim on 19.03.2012 11:23
CASE offset_diff = 0
Maybe you are looking for
-
Is anyone seeing the flashing globe on startup in Mavericks?
When I startup my MBA running Mavericks 10.9.2, I was geting a flashing globe and long delay before being presented with the Apple logo and, ultimatley, the login screen. For what it's worth, now that Activity Monitor no longer shows a disk usage pie
-
Contacts app says "waiting...", wont open
I dont use my contacts app directly very often, usually from within the mail or messaging app. I just now tried to open the contacts app and noticed it is stuck with "waiting" on both my iphone and iPad. Both running the most recent updates (8.1.3).
-
Why can't I use my credit card in OVI store?
After buying several apps in the Ovi Store using my credit card I was really surprised that Ovi Store does no longer accept my credit card because I'm not living in the US! (I'm requested to fill in a US address otherwise I cannot proceed.) **bleep**
-
Saving from Single User Mode???
ok, so my computer *****, and i just want to reformat the drive and start from scratchville. is there any way to have a USB Thumbdrive or external hard drive attached and move files from single user mode to the thumb drive to store it. and then once
-
I want to rotate images on refresh
I work for a newspaper, we want to rotate ads on refresh at random. We are looking to stop using our current programmer. We just need to figure this out. I want it to rotate like THIS. Is there a fairly simple way to do it in dreamweaver?