Thank you Stephen, for Fortnightly calculations, should I add plusDays(1) to endDate ? because If between 1/03/2009 - 21/03/2009 I got 2.5 fortnightly, while it should be 2 (set scale to round_down ?)
regards adwin On Sat, Mar 7, 2009 at 10:48 PM, Stephen Colebourne <scolebou...@joda.org> wrote: > adwin grails wrote: >> at the moment i am using Weeks.weeksBetwee(start,end) but it seems >> produce result not same with what I need. >> >> for example : >> import org.joda.time.DateTime; >> import org.joda.time.* ; >> >> def x = new DateTime().withDate(2009,03,01); >> def y = new DateTime().withDate(2009,03,21); >> >> def z = Days.daysBetween(x,y).getDays(); // produce 20 days >> def w = Weeks.weeksBetween(x,y).getWeeks(); // produce 2 weeks --> >> while it should be 3 weeks. > > The calculation is exclusive of the end date. Simply add one day to the > end date to make it inclusive > > def w = Weeks.weeksBetween(x,y.plusDays(1)).getWeeks(); > >> also how to calculate, for example the payment date is on every >> tuesday fortnightly (2 weeks) >> for example on 3/03/2009 and then 17/03/2009 and then 31/03/2009 ... >> if I have date range between 01.march.2009 - 31.july.2009 ... how to >> calculate how many fortnightly payments occurs during that period ? > > Calculate the number of weeks, divide by 2 and add one. > > Stephen > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Joda-interest mailing list > Joda-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/joda-interest > ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest