Function module to calculate no of days between two date ranges
hi experts,
can some one please suggest a function module that can calculate no of days between specified date range.
for example : if i enter date range between 26.02.2011 to 20.05.2011, then it should calculate no of days between these dates.
Moderator message : Basic date questions not allowed. Read forum rules before posting. Thread locked.
Edited by: Vinod Kumar on May 25, 2011 10:57 AM
Hi,
Please search SDN.. there are lots of posts for teh same.
[http://wiki.sdn.sap.com/wiki/display/ABAP/FunctionModulerelatedonDate+calculations]
Similar Messages
-
Function module to find no of days between two dates
hi everybody i want a function module to find no of days between two dates
Function module /SDF/CMO_DATETIME_DIFFERENCE
Uppercase/Lowercase
Runtime: 59,629 Microseconds
Import parameters Value
DATE1 01.01.2007
TIME1 00:00:00
DATE2 31.12.2007
TIME2 00:00:00
Export parameters Value
DATEDIFF 364 TIMEDIFF 0
EARLIEST 1 -
Calculate Difference in Days Between two Dates
Hi,
I'm trying to figure out how to calculate the difference in days between two dates using JavaScript in LiveCycle. (JavaScript knowledge = minimal)
Where "Start_Date" and "Current_Date" are the names of the two dates in the Hierarchy palette. (both Date/Time Field)
*Current date is using the Object > Value > Runtime Property > Current Date/Time
I need a Text or Numeric field displaying the difference in days. (Difference_in_Days)
I've noticed the following code being pretty standard amongst other responses:
var
Start_Date = new Date(Start_Date);
var
Current_Date = new Date(Current_Date);
var
nAgeMilliseconds = Current_Date.getTime() - Start_Date.getTime();
var
nMilliSecondsPerYear = 365 * 24 * 60 * 60 * 1000;
I know there's code missing, and the above code might not be correct.
Please advise.Where "DateField01" = user entered date field
Where "DateFiled02" = Current Date/Time (Runtime Property)
where "Subform" = the subform containing DateField01
My script now resembles:
var oneDay = 24*60*60*1000;
var firstDate = new Date(Subform.DateField01.rawValue);
var secondDate = new Date(DateField02.rawValue);
(firstDate.getTime() - secondDate.getTime()) / oneDay;
I tried adding:
app.alert(String(diffDays));
Although I assume the reason I didn't get an error is because DateField01 is empty when the form is opened.
If I swap in actual dates instead of fields it works perfectly.
When I use the fields I have no information populating after I enter a date in "DateField01" -
How to calculate number of days between two date in Template design?
Hello guys
I have a situation where I have to create a template that returns data, and one of the thing of the existing report is that there is a column that is actually the number of days between start date and end date columns..
So in template, how would I be able to do the same? I have start date and end date columns on the template, now when I created another column using expression like end date - start date and preview the template, I am getting errors saying :
Caused by: oracle.xdo.parser.v2.XPathException: Cannot convert 03/31/2009 to number.
at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
Please advice
ThanksHi
There is an extension function you can use, from the javadoc:
date_diff
public static long date_diff(java.lang.String format,
java.lang.String fromDate,
java.lang.String toDate,
java.lang.String locStr,
java.lang.String tzID)
Method to get the difference between two dates in the given locale. The dates need to be in "yyyy-MM-dd" format. This function supports only Gregorian calendar.
Parameters:
format - the format to which the difference is required; allowed formats are y (for Year), m(for month), w(for week), d(for day), h(for hour), mi(for minute), s(for seconds) and ms(for milliseconds)
fromDate - the first date
toDate - the second date
locStr - locale string -> lang-Territory
tzID - timezone ID ->http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html
Returns:
the difference in dates in the desired format
For example
<?xdoxslt:date_diff(‘d’,’2009-09-14’, ‘2009-09-20’,’en-US’,1)?>
give a result of 6
You can substitute in columns for the dates, just remember the date format required.
Regards
Tim -
Calculate difference of days between two dates
Hi,
Date1: It is a mandatory type-in date at the time of query execution. How to create it? By default, it should take today's calendar date.
Date2: it is a date in a Char format. (0NETDUEDATE) in one of the dimension of InfoCube.
In query column
of days = Date1 - Date2.
I would prefer to use in global variable.
Please help.
~SHello ,
For date 1 create a characteristic variable(ready to input) on 0calday with customer exit as processing type and key in the following code to get the system date.
data aktdat like sy-datum.
when 'test'.
aktdat = sy-datum(6).
clear l_s_range.
l_s_range-low = aktdat.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
append l_s_range to e_t_range.
Then create a user entry variable for date 2 using the characteristic mentioned,
then for calculating the days difference check the following.
http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html -
How to calculate days between two DATES
How to calculate days between two DATES ?
which is the functional module for that ?
help meHi,
use function module : it works,
HR_HK_DIFF_BT_2_DATES
give output format = 03 and get the value in days.
code is as below :
data : DATE1 type P0001-BEGDA,
DATE2 type P0001-BEGDA,
YEARS type P0347-SCRYY,
MONTHS type P0347-SCRMM,
DAYS type P0347-SCRDD.
date1 = '20070331'.
date2 = '20070101'.
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = date1
DATE2 = date2
OUTPUT_FORMAT = '03'
IMPORTING
YEARS = years
MONTHS = months
DAYS = days
EXCEPTIONS
INVALID_DATES_SPECIFIED = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write : days.
Reward points, if helpful,
Regards,
Sandeep Kaushik -
How can I calculate the maximum number of days between two dates in a range of dates?
I have a column of dates spanning the couse of a few months. I would like to know if I can calculate the maximum number of days between each row and display the highest number. I currently have another column that calculates the days betwen the rows and I am currently just looking at the totals and highlighting the highest period.
Is this possible? Any help or suggestions are appreciated.
Thank you,
TrevorThis sounds totally possible, Can you post a screen shot of your table to make responding more focused? If you mean you want to:
A) compute the difference (in days) between two date in the same row, then
B) find the max duration (in days)
Here is my take on this problem:
D2 = C2-B2
select D2 and fill down
F1=MAX(D)
to perform the conditional formatting (to highlight the max duration) select column D, then set up conditional formatting as shown in the 1st image -
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 Working Days between Two Dates
Hi All,
I'm creating a crystal report where I have to calculate the Number of Working Days between a date range, this should exclude the Weekends(done) but also exclude the public holidays which have defined in Holidays Calender.
I'm not using procedure or command, Operating directly with tables.
Any help would be appreciated.
Regards
Edited by: Pari Minhas on Nov 24, 2011 12:00 AMHi All,
I'm creating a crystal report where I have to calculate the Number of Working Days between a date range, this should exclude the Weekends(done) but also exclude the public holidays which have defined in Holidays Calender.
I'm not using procedure or command, Operating directly with tables.
Any help would be appreciated.
Regards
Edited by: Pari Minhas on Nov 24, 2011 12:00 AM -
Calculate business day between two dates
Hi Guys
I need the count of business days between two dates
Date1, Date2 i need the count only business day (exclude sartuday&sunday)
If date1 is null or nothing i need to pass 0
If date2 is null or nothing i need to pass 0
help on thisHi,
To achive this within SSRS, go to the report code window and add the below
Function getBusinessDaysCount(ByVal tFrom As Date, ByVal tTo As Date) As Integer
Dim tCount As Integer
Dim tProcessDate As Date = tFrom
For x as Integer= 1 To DateDiff(DateInterval.Day, tFrom, tTo) + 1
If Not (tProcessDate.DayOfWeek = DayOfWeek.Saturday Or tProcessDate.DayOfWeek = DayOfWeek.Sunday) Then
tCount = tCount + 1
End If
tProcessDate = DateAdd(DateInterval.Day, 1, tProcessDate)
Next
Return tCount
End Function
In the textbox where you need to display the value, add the below expression
=Code.getBusinessDaysCount(parameters!StartDate.Value,parameters!EndDate.Value)
It is assumed the you want to pass the two days from parameters named Startdate and EndDate. If not, modify the expression with required values.
Regards
Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful. BH -
Working days between two date fields and Changing Factory Calendar
Hi,
I have to calculate working days between two date fields excluding the weekends and public holidays for Switzerland.
I have written the routine using factory calender and its working fine except for two problems now:
1. If any one of the date field is empty then teh rsult should be zero.
2. And the below code is working from 1996 but my cleints wants it to work for years before 1996 as well.
I also tried to change the Start date in SCAL for factory calendar but it says enter values between 1995 to 2020.
I am new to ABAP. Please help me how i can achieve these for below code.
DATA: IT_HOLIDAYS type TABLE OF ISCAL_DAY,
IS_HOLIDAYS TYPE ISCAL_DAY.
DATA: T_DATE TYPE SY-DATUM,
P_DATE TYPE SY-DATUM.
DATA : X_DATE(4) TYPE C.
DATA: CNT TYPE I.
REFRESH : IT_HOLIDAYS.
CLEAR : IT_HOLIDAYS.
T_DATE = SOURCE_FIELDS-/BIC/ZCCCHP812.
P_DATE = SOURCE_FIELDS-/BIC/ZCCCHP810.
CALL FUNCTION 'HOLIDAY_GET'
EXPORTING
HOLIDAY_CALENDAR = 'CH'
FACTORY_CALENDAR = 'CH'
DATE_FROM = P_DATE
DATE_TO = T_DATE
TABLES
HOLIDAYS = IT_HOLIDAYS
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
DATE_HAS_INVALID_FORMAT = 3
DATE_INCONSISTENCY = 4
OTHERS = 5.
DESCRIBE TABLE IT_HOLIDAYS LINES CNT.
X_DATE = T_DATE - P_DATE - CNT.
RESULT = X_DATE.
Please help
Regards
Zabina
Edited by: Syed786 on Nov 2, 2011 9:15 AMHi Zabina,
Try this function module 'DURATION_DETERMINE'.
Give the factory calendar and unit as DAY
With regards,
Rajesh -
Calculation of MONTHS , YEARS , & DAYS between two dates
Hi Experts,
Currently i am using this functional Module. which calculates the number of months between two dates.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = ITAB_PER-BEGDA
I_DATE_TO = ITAB_PER-ENDDA
IMPORTING
E_MONTHS = CMONTHS.
BUT this functional module Rounding off the Month...Say ..if the total numbr of days between from & to date is 105 it is showing as 4 months ...
<b>Is there any other Functional Module</b> ????which Calculates the EXACT MONTH between two dates...(in the above case the month is expected to be 3 only since it is 105 days only)..
Kindly help me regarding this....lakshimiraja,
You can use this function module.
report zrich_0003
no standard page heading.
data: duration_in_months type i.
parameters: s_date type sy-datum,
e_date type sy-datum.
call function 'DURATION_DETERMINE'
exporting
unit = 'MON'
factory_calendar = 'P6' " Your factory calendar
importing
duration = duration_in_months
changing
start_date = s_date
end_date = e_date
exceptions
factory_calendar_not_found = 1
date_out_of_calendar_range = 2
date_not_valid = 3
unit_conversion_error = 4
si_unit_missing = 5
parameters_not_valid = 6
others = 7.
write:/ duration_in_months.
Don't forget to reward if useful... -
How to query the number of working days between two dates
I'm looking for a solution to calculate the number of <i>working</i> days between two dates that I can use in a formated search.
Calculating the total number of days is pretty straight forward but does anyone know how to take into account the settings in the HLD1 (Holiday Dates) table?Hi Eric,
If you are purely looking to exclude holidays defined in the HLD1 table, then you should be able to do it with the following query
NOTE: The following query is an example using OINV table and the fields DOCDATE and DOCDUEDATE for a Particular DOCNUM 'xxx'
If you planning to use within the SAP module then replace DOCDATE and DOCDUEDATE with dynamic field references $[$x.x.x]
SELECT DATEDIFF(DAY,T0.DOCDATE,T0.DOCDUEDATE)-
(SELECT COUNT(STRDATE) FROM HLD1 WHERE STRDATE >= T0.DOCDATE AND STRDATE <= T0.DOCDUEDATE)
FROM OINV T0
WHERE T0.DOCNUM = xxx
Best Wishes
Suda -
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 -
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.
Maybe you are looking for
-
Steps to link a report to Web Application Form. Post Your Opinion
Hi friends, After going through it what is your opinion. please do post your opinion. Could any one give the complete steps of Linking a report to web form so that when called / clicked the link the report can display the data. I have unchecked the "
-
ITunes Won't Open Because of Quicktime
I have a computer with Windows 7 Pro and I can't get iTunes to work correctly on it. I was getting an error message that was saying that iTunes couldn't open because Quicktime wasn't installed. However, quicktime is installed and working properly.
-
i everybody, i need to creat boxes to fill with quantity. can you help me please. thanxs a lot
-
S5000 4.4.2 OTA lag/slow system-wide, don't update!
Just installed the 4.4.2 on my S5000-H (3G version) and it lags like hell. The whole system. It used to be fairly snappy but now everything takes maybe a half second, even bringing up recent apps list or pressing home button. I feel it's a real downg
-
Hi, I have a problem with barcode kanban. I would like to create a production order through Barcode kanban. I get this error "No control cycle or kanban could be determined for the data specified" what can I do to customise the system so that it's w