on 07-07-2009 12:12 PM
Hi ,
Using the standard functions in XI, is it possible to add or subtract a fixed number of days from the date i get from the input file.
Like, from file I get the date as 25/06/2009.My output should be 05/07/2009 after adding 10 days .
can some one guide how to handle this.
Thanks,
Ven..
u can use 'SALP_CALC_DATE' which lets you add, delete days, weeks, months, quartes and years.
however there seems to be an error when youtry to subtract months; works as expected however when you add months or subtract days.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
imports: java.util.Calendar;java.text.SimpleDateFormat;java.text.DateFormat;
public String myYDF(String a,Container container){
String notifyDates = a;
Calendar calendar = Calendar.getInstance ( ) ;
DateFormat dateFormat = new SimpleDateFormat ( "yyyy-MM-dd" ) ;
try {
Date date = dateFormat.parse ( notifyDates ) ;
calendar.setTime ( date ) ;
calendar.add ( Calendar.DATE, 10 ) ; // For subtraction use calendar.add ( Calendar.DATE, -10 )
return dateFormat.format ( calendar.getTime ( ) ) ;
} catch ( Exception e ) {
return "error";
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
lOOK for
CALL FUNCTION '/SAPHT/DRM_CALC_DATE'
EXPORTING
date = l_datini
days = 1
months = 00
SIGN = '+'
years = 00
IMPORTING
calc_date = l_datini.
Best Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ven,
Here is a UDF code,which takes date(format:yyyyMMdd) as input and does addition or subtraction operations based on <field 1> value,return the result date(format:yyyyMMdd) as string value.
public String GenerateDate(String date_input, String field1,Container container){
//Here "date_input" and "field1" are inputs for this UDF
int date = Integer.parseInt(date_input);
Calendar cal;
int day = date % 100;
int month = (date/100) % 100 - 1;
int year = date / 10000;
cal = Calendar.getInstance();
cal.set(year, month, day);
/implement addition or subtraction logic here as your needs/
if (field1 == "A")
cal.add(Calendar.DATE, 10);
else if(field == "B")
cal.add(Calendar.DATE, -5);
day = cal.get(Calendar.DATE);
month = cal.get(Calendar.MONTH)+ 1;
year = cal.get(Calendar.YEAR);
date = year * 10000 + month * 100 + day;
return (""+date);
}
You can use Standard Funtion DateTrans to convert date from your format to the format used in the UDF and vice versa.
Regards
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ven,
Not sure if you can achieve this using standard functions.
YOu can try this Java Code in a UDF:
http://www.java-examples.com/add-or-substract-days-current-date-using-java-calendar
Regards,
Ravi Kanth Talagana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.