Add number of days to a date
Hi, all
somebody know if i can add days to a date with a dynamic action??
Thank for your help
Hi Francisco,
You can use a external subroutine to do so.
In the dynamic action:
for that infotype you can specify an entry with Step type F and Variable function part with the routine name(The new calculated date is returned in the RP50D-DATE1 field)
EXAMPLE:
STEP1 :In dynamic action create these 2 entries
0000| | | 06 | 457 | F | GET_DATE(ZHPADYN).
0000| | | 06 | 456 | W | P0041-DAT01=RP50D-DATE1
STEP2: Then create Subroutine pool in SE38 ( Program type S)
PROGRAM ZHPADYN.
TABLES : RP50D,
P0000.
*& Form GET_DATE
FORM GET_DATE .
RP50D-DATE1 = P0000-BEGDA - 1.
ENDFORM. "GET_DATE
Hope this helps.
Thanks,
Puneet
Similar Messages
-
Is it possible to add number of days to date?
I am working on a form where I need to add number of days to a date and come up with a date.
Header 1
Header 2
example date: March 1, 2013
+ 30
= march 31 2013
1. is this possible? Header1/cell 1 is a date field. Header 2/cell 1 is a dropdown field (30, 60, 90,120, custom),.
Header2 cell2 not sure what field to use date or text?
thank youNever mind I figured it out. Thanks
-
Need to add number of days to users end date.
Hi,
I have a code where we are adding number of days(30) to current date and then updating user's end date in IDM DB.
Now we have a requirement where we need to add number of days(30) to existing end date of user instead of adding to current date.
*public String incrementDate(int daysToAdd)
// Start date
log.info("NotifyLastDayOfService::incrementDate(): Enter");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, daysToAdd); // number of days to add
String newDate = sdf.format(c.getTime());
log.info("NotifyLastDayOfService::incrementDate(): Exit");
return newDate;
Have any body implemented this scenario?
Please suggest.
Thanks,
Kalpana.Hi Nayan,
Here is the code:
System.out.println("----inside increment date method-----");
HashMap<String, String> hm = new HashMap<String, String>();
HashMap<String,Date> modifyMap=new HashMap<String,Date>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
tcResultSet usrList = null;
String enddate = null;
hm.put("Users.Key",usrKey );
try {
usrList = this.usrIntf.findUsers(hm);
usrList.goToRow(0);
Date endDate =usrList.getDate("Users.End Date");
System.out.println("-----users end date-----"+endDate);
String userEndDate=sdf.format(endDate);
System.out.println("-----String value of users end date-----"+userEndDate);
Calendar cal=null;
System.out.println("-----Calender date-----"+cal);
cal.setTime(endDate);
System.out.println("-----end date-----"+endDate);
cal.add(Calendar.DATE, Integer.parseInt(daysToAdd)); // number of days to add
Date newEnddate = cal.getTime();
System.out.println("-----new end date-----"+newEnddate);
//usrList.setEndDate(Edate);
modifyMap.put(userEndDate,newEnddate);
usrIntf.updateUser(usrList, modifyMap);
System.out.println("updated user's end date in OIM DB");
//System.out.println("-----updated user's end date in OIM DB-----");
logger.info("NotifyLastDayOfService::incrementDate(): Exit");
System.out.println("-----new date-----");
} catch (tcAPIException e) {
logger.error("Error in finding end date for user" + e);
} catch (tcColumnNotFoundException e) {
logger.error("Error in finding end date for user" + e);
In th log file, I can see that the code is not executing this line:
cal.setTime(endDate);
end date is of type Date and stores users end date from DB. Please help in resolving this issue.
Thakns,
Kalpana. -
Get Date x number of days before current Date
How do you subtract x number of days from a Date object?
Is there a better way than
int x = 28; // number of days
long minisPerDay = 24 * 60 * 60 * 1000;
Date newDate = new Date (oldDate.getTime() - (x * minisPerDay );> How do you subtract x number of days from a Date object?
Calendar c = Calendar.getInstance();
c.setTime(yourDateInstance);
c.add(Calendar.DATE, -x);
Calculating Java dates: Take the time to learn how to create and use dates
Working in Java time: Learn the basics of calculating elapsed time in Java
Good luck! :o)
~ -
Can I create a field that calculates number of days from a date field?
Hi all,
I need a field that will calculate the number of days elapsed whatever date is entered into the date field, and update that number of days based on the calendar/computer calendar date. Does that make sense?
https://www.dropbox.com/s/arkmnsxjkl4r156/AFBS_FacilitySpecialCareList02.pdf
I set up the form so that my boss can add or subtract clients from the list. Each client needs to have its own "Days since added to the list" number. Sorta like a little aging report.
Is this possible?
Many thanks,
LauraWow, I'm so stumped. I tried to copy a bit of formcalc into the exit event for my current date field to try to make this happen, but I can't get it to work.
My attempt at scripting is embarrassing, but here it is:
form1.sf1.CCSub.CCGroup.#subform[0].DateField2::exit - (FormCalc, client)
form1.sf1.CCSub.CCGroup.#subform[0].NumericField2.rawValue = Date2Num(DateField1, "MM-DD-YY") - Date2Num(DateField2, "MM-DD-YY")
and here's the file:
https://www.dropbox.com/s/arkmnsxjkl4r156/AFBS_FacilitySpecialCareList02.pdf
Can anyone help me get this right?
Sign me: One Lost Designer
Thanks! -
Find Exact number of days between two dates
How can get the exact number of days between two dates?
An example of business days calculation in SQL */
/* The algorythm is: */
/* 1) Take the absolute difference between the dates */
/* to_date('&todate') - to_date('&frdate') */
/* 2) Subtract the weekends (number of weeks in the range */
/* TRUNC(to_date('&todate'),'D') = 1st day of week that */
/* end of period is in */
/* TRUNC(to_date('&frdate'),'D') = Last day of week that */
/* start of period is in */
/* So subtracting these two gives the number of days */
/* between the two dates but including all of the days in */
/* the weeks that the dates start and end in. When this */
/* number is divided by 7 it gives the number of weeks. */
/* Multiplying by 2 gives the number of weekend days. */
/* 3) Subtract 1 day if the ending date is on a saturday */
/* DECODE(to_char(to_date('&todate'),'D'),7,-1,0) */
/* --> If the day of the week is saturday (7), returns -1 */
/* 4) Subtract 1 day if the start date is on a sunday */
/* DECODE(to_char(to_date('&frdate'),'D'),1,-1) */
/* --> If the day of the week is sunday (1), returns 1 */
/* 5) Add one day to make the range inclusive (The '1 + ' ) */
/* Author: Kenneth Atkins ([email protected]) */
/* http://www.olywa.net/katkins/oratip */
define frdate = '&1'
define todate = '&2'
set verify off
select
'&frdate' From_Date
,'&todate' To_Date,
1 + to_date('&todate') - to_date('&frdate') -
((TRUNC(to_date('&todate'),'D') - TRUNC(to_date('&frdate'),'D'))/7)*2
+ DECODE(to_char(to_date('&todate'),'D'),7,-1,0)
+ DECODE(to_char(to_date('&frdate'),'D'),1,-1,0) Business_Days
from dual
Here is an example of running the script:
SQL> @busdays 01-AUG-96 15-AUG-96
FROM_DATE TO_DATE BUSINESS_DAYS
01-AUG-96 15-AUG-96 11 -
Getting number of days between 2 dates
Hello All,
I require the number of days between 2 dates.
The number of days is between low date : PR Date (not an input variable) and the high date.
I have created an customer exit variable to get sy-datum in made it as formula variable.
I have also created a formula variable for PR Date , and subtracted the 2 dates.
It is not giving the correct result.
Any suggestions.
Thanks & Regards,
VLRead through this web link. It will show you how to calculate the days between 2 dates directly in your BEX query.
No exit needed to calculate this.
http://teklink.co.uk/sap/sap-bi-bw-how-to-use-replacement-path-variables-to-perform-date-calculations-in-the-bex-analyzer/ -
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 -
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);
} -
How to calculate number of days from a date field
Dear BW Experts.
I have a field 'Create Date' in the BEx query. Now we need to create a variable which should give the number of days from the date of running the query (sy-datum) to the Create Date.
This will help the users to get records which are say, 30 days old (Sy-datum - create date = 30) or 10 days old etc.
Could you suggest as to how to create this variable.
Thanks,
SaiHi,
Step 1: Create variable on "Create Date" with User entry processing type
Step 2: Create a restricted KF for Sales & restrict it on "Create Date" to get "Sales on day"
Step 3: Manipulate the values of "Create Date" on which you could restrict "Sales" again and again to get other values
Step 4: Create one variable (ZPUTMNTH) for u201CMonth to Dateu201D with processing by u201CCustomer Exitu201D. This variable was created on u201CDateu201D characteristics.
Step 5 : Goto C-mod t-code and use EXIT_SAPLRRS0_001
to calculate "month to date" user input is "Calday" Key Date
WHEN 'ZPUTMNTH'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZPDATE'.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(6). "low value, e.g.YYYYMM (200606) part of key date (20060625)
L_S_RANGE-LOW+6(2) = '01'. u201C low value e..g. YYYYMM01 (20060601)
L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
Assign if helps.....
Regards,
Suman -
Number of days in given date/month
Hi,
Can you send query to find the number of days in given date/month
Regards,
Venkat.If you want No. of days between two date then you can just Subtract them. If you want the number of days in a month you can get the first and last day of the month and subtract them.
Solution for a month.
SQL> with t as (select to_date('&month','mmyyyy') as dt from dual)
2 select (last_day(dt) - trunc(dt, 'mm'))+1
3 from t
4 /
Enter value for month: 012009
old 1: with t as (select to_date('&month','mmyyyy') as dt from dual)
new 1: with t as (select to_date('012009','mmyyyy') as dt from dual)
(LAST_DAY(DT)-TRUNC(DT,'MM'))+1
31
SQL> /
Enter value for month: 022009
old 1: with t as (select to_date('&month','mmyyyy') as dt from dual)
new 1: with t as (select to_date('022009','mmyyyy') as dt from dual)
(LAST_DAY(DT)-TRUNC(DT,'MM'))+1
28
SQL> /
Enter value for month: 122009
old 1: with t as (select to_date('&month','mmyyyy') as dt from dual)
new 1: with t as (select to_date('122009','mmyyyy') as dt from dual)
(LAST_DAY(DT)-TRUNC(DT,'MM'))+1
31Edited by: Karthick_Arp on Feb 19, 2009 9:56 PM -
Number of days between two dates
I have two dates-String Date1, String Date2(format of both the dates is 'DD-MM-YY'eg;'28-Jan-2008'). I want to find the difference between these dates;ie if value of String Date1 is '28-Jan-2008' and value of String Date2 is '28-Jan-2009', I need to find the number of days between these dates. What need to be done? Can anyone help me out please.
Thanks in advance for all the help.
Regards,
AneesDoing a search is a bit ineffiecient. I'd take advantage of the fact that dates are acually stored in milliseconds. Subtract the two millisecond values (Data.getTime()) and divide by the number of milliseconds in a day. One complication, though, is daylight saving time but if you round rather than truncate in the division it should be fine.
private static final long MILLIS_PER_DAY = 24L * 60L * 60L * 1000L;
int dayDiff = (int)((date2.getTime() - date1.getTime() + MILLIS_PER_DAY/2) / MILLIS_PER_DAY); -
Number of days between to dates
Hello to all,
I would like to define a formula to calculate number of days between two dates and update the value in a key figure.
*operand: {Name of keyfigure,Fecha ini (Mes/Año),Fecha Fin (Mes/Año)}
DATA FECHAINI TYPE ZIOV_FEIN.
DATA FECHAFIN TYPE ZIOV_FFIM.
DATA INI TYPE 0CALMONTH.
DATA FIN TYPE 0CALMONTH.
DATA DIA_INI TYPE D.
DATA DIA_FIN TYPE D.
DATA DIAS TYPE F.
FOREACH FECHAINI, FECHAFIN.
INI = FECHAINI.
FIN = FECHAFIN.
*C2DATE Determine end period date
DIA_INI = C2DATE(INI, E).
DIA_FIN = C2DATE(FIN, E).
DIAS = DIA_FIN - DIA_INI.
{ZIOV_DIAS,FECHAINI,FECHAFIN} = DIAS.
ENDFOR.
Problem: UPF057 type F conflicts with type D.
Help would be much appreciated.
Regards,
PatríciaThe function is built in:
CALL METHOD CL_RSAR_FUNCTION=>DATE_DIFF(
EXPORTING I_DATE_1 = L_ARG2
I_DATE_2 = L_ARG3
IMPORTING E_RESULT = L_ARG1 ) -
How do i get number of days between 2 dates?
How do i get number of days between 2 dates?
and the result must be in int.
for example
Ex. startdate: 2006-06-01 enddate: 2006-06-30 and the result is: 30
how to do so? thxmel
Iv'e used this method. It assumes startdate,enddate and days have been defined before but you could pass them as args.
void days()
try
Date d1 = DateFormat.getDateInstance().parse(startdate);
Date d2 = DateFormat.getDateInstance().parse(enddate);
long days = (d2.getTime()-d1.getTime())/1000/60/60/24;
days = ""+days;
catch (ParseException e)
System.out.println("Invalid date format");
}It actually gets the duration in ms and divides down to days.
Regards
Chris -
Number of days between 2 dates
HI,
I am working on a program that needs to show number of days between 2 dates. When I scanned the function library, I only found a function to give you the number of years between dates. I can probably code this in ABAP but does anyone know if a function exists to do this.Hi Suneela
Are you concern with the normal dates or do you have any concern with the Factory dates ?
Lets take both
1) Normal dates
It seems that you are trying to get the days between two dates , That you can simply get by subtracting one from the other or else by .
Assuming that you populated the dates just after the declaration .
Sample code
Data : date1 like sy-datum,
Date2 like sy-datum ,
No_of_days type i.
No_of_days = date1 date2.
Or Else the FM
Days_between_two_dates
Sample code
Data : date1 like sy-datum,
Date2 like sy-datum ,
No_of_days type i.
Call function days_between_two_dates
Exporting
I_datum_bis = Date2 Second date
I_datum_von = date1 Start date
Importing
E_tage = No_of_days
Exceptions
Days_method_not_defined = 1
Others = 2.
2) Factory dates
If You want to find out the difference based on factory calendar
Then convert the dates to factory calendar dates first and then simply subtract those factory calendar dates to get offset days based on factory calendar.
*Sample code *
Data : date1 like sy-datum,
Date2 like sy-datum ,
No_of_days type i.
data: l_fac_date like SCAL-FACDATE , " Factory calendar: Factory
l_fac_date2 like SCAL-FACDATE,
l_fac_date1 like SCAL-FACDATE.
Perform get_factory_date using date1
Changing l_fac_date1.
Form get_factory_date using l_date
Changing l_l_fac_date.
IF NOT l_date1 IS INITIAL.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
CORRECT_OPTION = '+'
DATE = l_date
FACTORY_CALENDAR_ID = 'AU' "
IMPORTING
DATE =
FACTORYDATE = l_l_fac_date
WORKINGDAY_INDICATOR =
EXCEPTIONS
CALENDAR_BUFFER_NOT_LOADABLE = 1
CORRECT_OPTION_INVALID = 2
DATE_AFTER_RANGE = 3
DATE_BEFORE_RANGE = 4
DATE_INVALID = 5
FACTORY_CALENDAR_NOT_FOUND = 6
OTHERS = 7
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
Endform.
Move l_fac_date to l_fac_date1.
*Do the same for the second date also i.e .
Perform get_factory_date using date2
Changing l_fac_date2.
No_of_days = l_fac_date1 - l_fac_date2.
Hope this will help you.
Reward points if helpful
Maybe you are looking for
-
Execution of Clob through dynamic sql
Hi, Here in below code.I am trying to execute the CLOB dynamically.Its giving an error as ORA-6502 Numeric or value error. Declare SQL3 CLOB := ''; SQLSTRING1 LONG; SQLSTRING2 LONG; SQLSTRING3 LONG; Begin SQL3 := GENUPD(RECTABLE => 'REC_TARGET_TABLE'
-
Need to suppress warning message while executing querywith conditions.
Hi, I have created report in which I have two conditions in report I am showing report data only if keyfigure value is greator than 4. In characteristics I have calmonth and customer I want to suppress result row so supress result row is always but
-
Hi Experts I am trying to implement a simple file lookup, can any one tell me which package i need to import while writing the UDF.I am getting an error message ("cannot resolve symbol URL class and URL connection class") which package is to be impo
-
Restore ASR System Reserved Partition
Hi community. My ASR Boot environment has been damaged when my colleague inadvertently loaded a windows 7 standard image to my RAID array. After moving the Windows 7 installation back to the dedicated drive and off my RAID array i configured the Boo
-
af:panelTabbed af:showDetailItem not working in Windows 8, IE 10
Hi , I am facing some issues in Win 8 IE 10 platform.There is one page that contains panel tabbed dialog control .I am not able to open the tabs inside it.It was working fine in IE 9,IE 10 compatibility view . Is there any known issue for pannel tabb