Re: Easiest way to count months in range?

2012-07-26 Thread Man-wai Chang
Ask the user what defines a month! It could be 30 days or gomonth(date, 1) or... You might want to code this as an option selectable by the user. On Thu, Jul 26, 2012 at 4:38 AM, MB Software Solutions, LLC mbsoftwaresoluti...@mbsoftwaresolutions.com wrote: Input is 2 dates...I need to count the

RE: Easiest way to count months in range?

2012-07-26 Thread Christina Bull
Hey, I do something like this for a hiring company when working out overhire extension invoices. Some of them I have to work out weeks and others get calculated in months. I use this and it works for me. They don't have anything more than 2 years old (famous last words...) that need extending

Easiest way to count months in range?

2012-07-25 Thread MB Software Solutions, LLC
Input is 2 dates...I need to count the number of months between (and including) them. example: 2012-02-27 to 2013-01-31 would be 13. Thought this might yield some interesting approaches. :-) -- Mike Babcock, MCP MB Software Solutions, LLC President, Chief Software Architect

Re: Easiest way to count months in range?

2012-07-25 Thread Fred Taylor
What constitutes a month? Is 2012-06-30 to 2012-07-01 one month or two? And how would your example be 13? Fred On Wed, Jul 25, 2012 at 1:38 PM, MB Software Solutions, LLC mbsoftwaresoluti...@mbsoftwaresolutions.com wrote: Input is 2 dates...I need to count the number of months between (and

Re: Easiest way to count months in range?

2012-07-25 Thread MB Software Solutions, LLC
On 7/25/2012 4:45 PM, Fred Taylor wrote: What constitutes a month? Is 2012-06-30 to 2012-07-01 one month or two? And how would your example be 13? Hi Fred, Sorry...forgot to say disregard the day in the month. Here's what I came up with. It's a bit verbose but it's for clarity's sake:

Re: Easiest way to count months in range?

2012-07-25 Thread MB Software Solutions, LLC
On 7/25/2012 4:45 PM, Fred Taylor wrote: What constitutes a month? Is 2012-06-30 to 2012-07-01 one month or two? And how would your example be 13? Fred On Wed, Jul 25, 2012 at 1:38 PM, MB Software Solutions, LLC mbsoftwaresoluti...@mbsoftwaresolutions.com wrote: Input is 2 dates...I

Re: Easiest way to count months in range?

2012-07-25 Thread Paul Hill
Hi Mike, Can't you just do: dDate1 = {27/02/2012} dDate2 = {31/01/2013} nMonths = (Year(dDate2)*12 + Month(dDate2)) - (Year(dDate1)*12 + Month(dDate1)) + 1 Paul On 25 July 2012 21:57, MB Software Solutions, LLC mbsoftwaresoluti...@mbsoftwaresolutions.com wrote: On 7/25/2012 4:45 PM, Fred

Re: Easiest way to count months in range?

2012-07-25 Thread Fred Taylor
LOCAL m.d1, m.d2, m.nMons m.d1 = {^2012/02/27} m.d2 = {^2013/01/31} m.d1 = {^2012/06/30} m.d2 = {^2012/07/01} m.nMons = MonthRange(m.d1, m.d2) ? m.nMons FUNCTION MonthRange(m.tdFrom, m.tdTo) LOCAL m.nM, m.dTest, m.dEnd m.nM = 0 m.dTest = m.tdFrom - DAY(m.tdFrom) + 1 1st of the begin month m.dEnd

Re: Easiest way to count months in range?

2012-07-25 Thread Sytze de Boer
I never reply to this kind of email because I leave it to you gurus However, I was just working with a live system where I use this formula today=date() m1=(year(trans.date)*12)+month(trans.date) m2=(year(today)*12)+month(today) lvMonths=m2-m1 On Thu, Jul 26, 2012 at 9:20 AM, Fred Taylor

Re: Easiest way to count months in range?

2012-07-25 Thread Paul Hill
On 25 July 2012 22:26, Sytze de Boer sytze.k...@gmail.com wrote: I never reply to this kind of email because I leave it to you gurus However, I was just working with a live system where I use this formula today=date() m1=(year(trans.date)*12)+month(trans.date)

Re: Easiest way to count months in range?

2012-07-25 Thread MB Software Solutions, LLC
On 7/25/2012 5:31 PM, Paul Hill wrote: On 25 July 2012 22:26, Sytze de Boer sytze.k...@gmail.com wrote: I never reply to this kind of email because I leave it to you gurus However, I was just working with a live system where I use this formula today=date()

Re: Easiest way to count months in range?

2012-07-25 Thread Stephen Russell
On Wed, Jul 25, 2012 at 4:41 PM, MB Software Solutions, LLC mbsoftwaresoluti...@mbsoftwaresolutions.com wrote: On 7/25/2012 5:31 PM, Paul Hill wrote: On 25 July 2012 22:26, Sytze de Boer sytze.k...@gmail.com wrote: I never reply to this kind of email because I leave it to you gurus However, I

Re: Easiest way to count months in range?

2012-07-25 Thread Fred Taylor
Here, one less multiply by 12: ?(YEAR(m.d2)-YEAR(m.d1))*12 + MONTH(m.d2)-MONTH(m.d1)+1 Fred On Wed, Jul 25, 2012 at 2:41 PM, MB Software Solutions, LLC mbsoftwaresoluti...@mbsoftwaresolutions.com wrote: On 7/25/2012 5:31 PM, Paul Hill wrote: On 25 July 2012 22:26, Sytze de Boer