on 06-15-2006 10:33 AM
Hi All ,
I need to calculate the date difference between two dates in XI . I did not find any standard function given in XI .
Thanks in Advance
Chan
You can create a define funcation in side which you can write java code which will calculate days for you.
This user define funcation should have two inputs as dates. and out can be days.
inside that user define funcation you can have following logic
similar to this
GregorianCalendar da1 = new GregorianCalendar(2004,0,1,1,1,1);
GregorianCalendar da2 = new GregorianCalendar(2004,1,9,8,5,10);
long d1 = da1.getTime().getTime();
long d2 = da2.getTime().getTime();
long difMil = d2-d1;
long milPerDay = 1000*60*60*24;
long milPerOra = 1000*60*60;
long milPerMin = 1000*60;
long milPerSec = 1000;
long days = difMil / milPerDay;
long ore = ( difMil - days*milPerDay ) / milPerOra;
long min = ( difMil - days*milPerDay - ore*milPerOra ) / milPerMin;
long sec = ( difMil - days*milPerDay - ore*milPerOra - min*milPerMin ) / milPerSec;
long mil = ( difMil - days*milPerDay - ore*milPerOra - min*milPerMin - sec*milPerSec );
System.out.println("days="+days+" ore="+ore+" min="+min+" sec="+sec+" mil="+mil);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
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.