Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10671

Re: UDF for comparing Date

$
0
0

Hi Sherin,

               Please try this UDF

 

public static String compareDates(String startDate,String EndDate)
{      String difference="";
 try
 {       String pattern = "yyyy-MM-dd";       long  diff;       final long  MilliSecondsInADay=1000 * 60 * 60 * 24 ;       java.text.SimpleDateFormat Dateformat = new java.text.SimpleDateFormat(pattern);       java.util.Date endDate= Dateformat.parse(EndDate);       java.util.Date StartDate= Dateformat.parse(startDate);       diff=(endDate.getTime()-StartDate.getTime())/MilliSecondsInADay;       if(diff<0)       {             diff=-diff;       }       difference=""+diff;
 }
 catch(java.text.ParseException e)
 {       e.printStackTrace();
 }
 return difference;
}

 

 

Regards

Anupam


Viewing all articles
Browse latest Browse all 10671

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>