on 01-20-2009 8:42 AM
Hi All,
Can find no. of days between 2 dates with simple logic or using any function module?
Thank you,
Prasanna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasanna,
Use this function module "DAYS_BETWEEN_TWO_DATES"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can find the difference of two days using simple UDF functions.
import java.util.Calendar;
Create the UDF.
Regards
Sunil.
Here it goes..
import java.util.Calendar;
//write your code here
// Pass the Date format as YYYY.MM.DD. if the inputs format are diffeernt change the substring function accordingly.
String a1 = a.substring(0,4);
String a2 = a.substring(5,7);
String a3 = a.substring(8,10);
String b1 = b.substring(0,4);
String b2 = b.substring(5,7);
String b3 = b.substring(8,10);
//If you are getting the input as integer it can be direclty passed. Here the UDF is getting the date value as string.
//Convert the String into Int.
int a11 = Integer.parseInt(a1);
int a21 = Integer.parseInt(a2);
int a31 = Integer.parseInt(a3);
int b11 = Integer.parseInt(b1);
int b21 = Integer.parseInt(b2);
int b31 = Integer.parseInt(b3);
Calendar calendar1 = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
//Set the date
calendar1.set(a11, a21, a31);
calendar2.set(b11, b21, b31);
long milliseconds1 = calendar1.getTimeInMillis();
long milliseconds2 = calendar2.getTimeInMillis();
long diff = milliseconds2 - milliseconds1;
diff = Math.abs(diff);
long diffDays = diff / (24 * 60 * 60 * 1000);
String diff1 = Long.toString(diffDays);
return diff1;
Edited by: Sunil John on Jan 20, 2009 5:26 PM
Deleted
Edited by: Prateek Raj Srivastava on Jan 20, 2009 9:50 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
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.