Return to Snippet

Revision: 9888
at November 28, 2008 04:24 by kouphax


Initial Code
def monthsBetween(from, to){

        def cfrom = new GregorianCalendar(time:from)
        def cto   = new GregorianCalendar(time:to)
        
        return ((cto.get(Calendar.YEAR) - cfrom.get(Calendar.YEAR)) 
            * cto.getMaximum(Calendar.MONTH)) 
            + (cto.get(Calendar.MONTH) - cfrom.get(Calendar.MONTH))
    }

Initial URL

                                

Initial Description
Calculates the number of Months between 2 given dates

Initial Title
Calculate Number of Months Between 2 Dates

Initial Tags
groovy

Initial Language
Groovy