on 09-08-2015 10:16 AM
Hi,
Could someone please provide me the code for simple UDF to get the next Business Day?
Thanks in Advance.
Hi Anuradha,
Please try it with below code,
Date today
= new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(today);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == Calendar.FRIDAY)
{
calendar.add(Calendar.DATE, 3);
}
else if (dayOfWeek == Calendar.SATURDAY)
{
calendar.add(Calendar.DATE, 2);
}
else
{
calendar.add(Calendar.DATE, 1);
}
Date nextBusinessDay = calendar.getTime();
int y = calendar.get(Calendar.YEAR);
int d = calendar.get(Calendar.DAY_OF_MONTH);
int m =calendar.get(calendar.MONTH)+1;
String dd = d+"";
String mm = m+"";
if(dd.length()==1)
dd = "0"+dd;
if(mm.length()==1)
mm = "0"+mm;
return ""+y+""+mm+""+dd;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the inputs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anuradha,
The business days change in every country, region, city and so on. You will need a system that you have the business calendar loaded, if you have a SAP ECC in your environment you can try with a RFC lookup to take this information.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.