A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do I create formula to calc difference in dates?



 
 
Thread Tools Display Modes
  #11  
Old February 18th, 2009, 04:28 PM posted to microsoft.public.excel.misc
VSlaybaugh
external usenet poster
 
Posts: 12
Default How do I create formula to calc difference in dates?

Wow! This works great. I appreciate your quick responses when I submit a
problem I'm having. You always have a solution that works. I just wish I
understood what you did to make it happen. :-)

"T. Valko" wrote:

Try this:

E16 = start date
F16 = end date

=SUMPRODUCT(--(DAY(ROW(INDIRECT(E16&":"&F16)))=20))

That will count how many 20th of the months there are from a start date to
an end date (inclusive).

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
I have tried this function but am having trouble with it returning the
right
value. I have an end-date of 1/20/2010 (in cell F16) and a start-date of
2/11/2009 (in cell E16). I'm trying to calculate how many automatic
monthly
transfers there will be on the 20th of each month but the function is
returning a value of 11 when it should return a value of 12. The first
transfer will be 2/20/2009 and the last transfer will be 1/20/2010.a total
of
12 transfers.

"David Biddulph" wrote:

I hope that Dec 2008 - Jan 2006 is 35, rather than 23. :-)

An alternative to DATEDIF would be
=MONTH(A1)-MONTH(B1)+12*(YEAR(A1)-YEAR(B1))
Note that if you have different dates within the start and end months,
you'll get different results from the 2 formulae.
End of Jan to beginning of Feb gives a 1 month difference with the
original
=MONTH(A1)-MONTH(B1) and with my extension thereto, but DATEDIF counts
completed months (with various questions when months are of unequal
length).
--
David Biddulph

"Ron Rosenfeld" wrote in message
...
On Sun, 30 Dec 2007 18:37:01 -0800, Mike

wrote:

=MONTH(A1)-MONTH(B1)

That works when the two months are in the same year, but what if they
are
in
different years? For example January 2008-September 2007 = -8, but
should
equal 4. Or December 2008-January 2006 = 11, but should equal 23.

Use the undocumented DATEDIF function:

=DATEDIF(B1,A1,"m")

(The first date must be the earlier date).


See http://www.cpearson.com/Excel/datedif.aspx for documentation.

--ron






  #12  
Old February 18th, 2009, 06:04 PM posted to microsoft.public.excel.misc
T. Valko
external usenet poster
 
Posts: 15,759
Default How do I create formula to calc difference in dates?

You're welcome. Thanks for the feedback!

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
Wow! This works great. I appreciate your quick responses when I submit a
problem I'm having. You always have a solution that works. I just wish I
understood what you did to make it happen. :-)

"T. Valko" wrote:

Try this:

E16 = start date
F16 = end date

=SUMPRODUCT(--(DAY(ROW(INDIRECT(E16&":"&F16)))=20))

That will count how many 20th of the months there are from a start date
to
an end date (inclusive).

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
I have tried this function but am having trouble with it returning the
right
value. I have an end-date of 1/20/2010 (in cell F16) and a start-date
of
2/11/2009 (in cell E16). I'm trying to calculate how many automatic
monthly
transfers there will be on the 20th of each month but the function is
returning a value of 11 when it should return a value of 12. The first
transfer will be 2/20/2009 and the last transfer will be 1/20/2010.a
total
of
12 transfers.

"David Biddulph" wrote:

I hope that Dec 2008 - Jan 2006 is 35, rather than 23. :-)

An alternative to DATEDIF would be
=MONTH(A1)-MONTH(B1)+12*(YEAR(A1)-YEAR(B1))
Note that if you have different dates within the start and end months,
you'll get different results from the 2 formulae.
End of Jan to beginning of Feb gives a 1 month difference with the
original
=MONTH(A1)-MONTH(B1) and with my extension thereto, but DATEDIF counts
completed months (with various questions when months are of unequal
length).
--
David Biddulph

"Ron Rosenfeld" wrote in message
...
On Sun, 30 Dec 2007 18:37:01 -0800, Mike

wrote:

=MONTH(A1)-MONTH(B1)

That works when the two months are in the same year, but what if
they
are
in
different years? For example January 2008-September 2007 = -8, but
should
equal 4. Or December 2008-January 2006 = 11, but should equal 23.

Use the undocumented DATEDIF function:

=DATEDIF(B1,A1,"m")

(The first date must be the earlier date).


See http://www.cpearson.com/Excel/datedif.aspx for documentation.

--ron








  #13  
Old April 15th, 2009, 12:31 PM posted to microsoft.public.excel.misc
Imran ul Haque
external usenet poster
 
Posts: 1
Default How do I create formula to calc difference in dates?

Can you help me in finding difference of data between 12/10/2003 &
2/14/2009. With datedif or usual cell1 - cell2 formulae it shows 1893 days
where as my manual calculation shows it to be
Year Days
2003 52
2004 360
2005 360
2006 360
2007 360
2008 360
2009 45
Total 1897

Appreciate you help.
Imran


"T. Valko" wrote:

You're welcome. Thanks for the feedback!

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
Wow! This works great. I appreciate your quick responses when I submit a
problem I'm having. You always have a solution that works. I just wish I
understood what you did to make it happen. :-)

"T. Valko" wrote:

Try this:

E16 = start date
F16 = end date

=SUMPRODUCT(--(DAY(ROW(INDIRECT(E16&":"&F16)))=20))

That will count how many 20th of the months there are from a start date
to
an end date (inclusive).

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
I have tried this function but am having trouble with it returning the
right
value. I have an end-date of 1/20/2010 (in cell F16) and a start-date
of
2/11/2009 (in cell E16). I'm trying to calculate how many automatic
monthly
transfers there will be on the 20th of each month but the function is
returning a value of 11 when it should return a value of 12. The first
transfer will be 2/20/2009 and the last transfer will be 1/20/2010.a
total
of
12 transfers.

"David Biddulph" wrote:

I hope that Dec 2008 - Jan 2006 is 35, rather than 23. :-)

An alternative to DATEDIF would be
=MONTH(A1)-MONTH(B1)+12*(YEAR(A1)-YEAR(B1))
Note that if you have different dates within the start and end months,
you'll get different results from the 2 formulae.
End of Jan to beginning of Feb gives a 1 month difference with the
original
=MONTH(A1)-MONTH(B1) and with my extension thereto, but DATEDIF counts
completed months (with various questions when months are of unequal
length).
--
David Biddulph

"Ron Rosenfeld" wrote in message
...
On Sun, 30 Dec 2007 18:37:01 -0800, Mike

wrote:

=MONTH(A1)-MONTH(B1)

That works when the two months are in the same year, but what if
they
are
in
different years? For example January 2008-September 2007 = -8, but
should
equal 4. Or December 2008-January 2006 = 11, but should equal 23.

Use the undocumented DATEDIF function:

=DATEDIF(B1,A1,"m")

(The first date must be the earlier date).


See http://www.cpearson.com/Excel/datedif.aspx for documentation.

--ron









  #14  
Old April 15th, 2009, 12:35 PM posted to microsoft.public.excel.misc
Imran ul Haque[_2_]
external usenet poster
 
Posts: 1
Default How do I create formula to calc difference in dates?

sorry but the actual manual calculation is as follows:

Year Days
2003 52
2004 364
2005 364
2006 365
2007 364
2008 364
2009 45
Total days 1918


"Imran ul Haque" wrote:

Can you help me in finding difference of data between 12/10/2003 &
2/14/2009. With datedif or usual cell1 - cell2 formulae it shows 1893 days
where as my manual calculation shows it to be
Year Days
2003 52
2004 360
2005 360
2006 360
2007 360
2008 360
2009 45
Total 1897

Appreciate you help.
Imran


"T. Valko" wrote:

You're welcome. Thanks for the feedback!

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
Wow! This works great. I appreciate your quick responses when I submit a
problem I'm having. You always have a solution that works. I just wish I
understood what you did to make it happen. :-)

"T. Valko" wrote:

Try this:

E16 = start date
F16 = end date

=SUMPRODUCT(--(DAY(ROW(INDIRECT(E16&":"&F16)))=20))

That will count how many 20th of the months there are from a start date
to
an end date (inclusive).

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
I have tried this function but am having trouble with it returning the
right
value. I have an end-date of 1/20/2010 (in cell F16) and a start-date
of
2/11/2009 (in cell E16). I'm trying to calculate how many automatic
monthly
transfers there will be on the 20th of each month but the function is
returning a value of 11 when it should return a value of 12. The first
transfer will be 2/20/2009 and the last transfer will be 1/20/2010.a
total
of
12 transfers.

"David Biddulph" wrote:

I hope that Dec 2008 - Jan 2006 is 35, rather than 23. :-)

An alternative to DATEDIF would be
=MONTH(A1)-MONTH(B1)+12*(YEAR(A1)-YEAR(B1))
Note that if you have different dates within the start and end months,
you'll get different results from the 2 formulae.
End of Jan to beginning of Feb gives a 1 month difference with the
original
=MONTH(A1)-MONTH(B1) and with my extension thereto, but DATEDIF counts
completed months (with various questions when months are of unequal
length).
--
David Biddulph

"Ron Rosenfeld" wrote in message
...
On Sun, 30 Dec 2007 18:37:01 -0800, Mike

wrote:

=MONTH(A1)-MONTH(B1)

That works when the two months are in the same year, but what if
they
are
in
different years? For example January 2008-September 2007 = -8, but
should
equal 4. Or December 2008-January 2006 = 11, but should equal 23.

Use the undocumented DATEDIF function:

=DATEDIF(B1,A1,"m")

(The first date must be the earlier date).


See http://www.cpearson.com/Excel/datedif.aspx for documentation.

--ron









  #15  
Old April 15th, 2009, 01:01 PM posted to microsoft.public.excel.misc
Fred Smith[_4_]
external usenet poster
 
Posts: 2,386
Default How do I create formula to calc difference in dates?

Imran,

First, if you have a new query, start a new thread. When you add to an
existing thread, there's too much chance it will get lost.
Second, there are 365 days in a year, not 364. In leap years, there are 366.
Third, you need to be consistent in your date formats. Because the second
date can only be Feb 14/09, the first date must be Dec 10/03, not Oct 12.

So, your actual days in between a
2003: 21
2004: 366
2005: 365
2006: 365
2007: 365
2008: 366
2009: 45
Total: 1893

Regards,
Fred.

"Imran ul Haque" wrote in message
...
sorry but the actual manual calculation is as follows:

Year Days
2003 52
2004 364
2005 364
2006 365
2007 364
2008 364
2009 45
Total days 1918


"Imran ul Haque" wrote:

Can you help me in finding difference of data between 12/10/2003 &
2/14/2009. With datedif or usual cell1 - cell2 formulae it shows 1893
days
where as my manual calculation shows it to be
Year Days
2003 52
2004 360
2005 360
2006 360
2007 360
2008 360
2009 45
Total 1897

Appreciate you help.
Imran


"T. Valko" wrote:

You're welcome. Thanks for the feedback!

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
Wow! This works great. I appreciate your quick responses when I
submit a
problem I'm having. You always have a solution that works. I just
wish I
understood what you did to make it happen. :-)

"T. Valko" wrote:

Try this:

E16 = start date
F16 = end date

=SUMPRODUCT(--(DAY(ROW(INDIRECT(E16&":"&F16)))=20))

That will count how many 20th of the months there are from a start
date
to
an end date (inclusive).

--
Biff
Microsoft Excel MVP


"VSlaybaugh" wrote in message
...
I have tried this function but am having trouble with it returning
the
right
value. I have an end-date of 1/20/2010 (in cell F16) and a
start-date
of
2/11/2009 (in cell E16). I'm trying to calculate how many
automatic
monthly
transfers there will be on the 20th of each month but the function
is
returning a value of 11 when it should return a value of 12. The
first
transfer will be 2/20/2009 and the last transfer will be
1/20/2010.a
total
of
12 transfers.

"David Biddulph" wrote:

I hope that Dec 2008 - Jan 2006 is 35, rather than 23. :-)

An alternative to DATEDIF would be
=MONTH(A1)-MONTH(B1)+12*(YEAR(A1)-YEAR(B1))
Note that if you have different dates within the start and end
months,
you'll get different results from the 2 formulae.
End of Jan to beginning of Feb gives a 1 month difference with
the
original
=MONTH(A1)-MONTH(B1) and with my extension thereto, but DATEDIF
counts
completed months (with various questions when months are of
unequal
length).
--
David Biddulph

"Ron Rosenfeld" wrote in message
...
On Sun, 30 Dec 2007 18:37:01 -0800, Mike

wrote:

=MONTH(A1)-MONTH(B1)

That works when the two months are in the same year, but what
if
they
are
in
different years? For example January 2008-September 2007 = -8,
but
should
equal 4. Or December 2008-January 2006 = 11, but should equal
23.

Use the undocumented DATEDIF function:

=DATEDIF(B1,A1,"m")

(The first date must be the earlier date).


See http://www.cpearson.com/Excel/datedif.aspx for
documentation.

--ron










  #16  
Old September 6th, 2009, 02:14 PM posted to microsoft.public.excel.misc
Dipesh
external usenet poster
 
Posts: 2
Default How do I create formula to calc difference in dates?



"dlcroswell" wrote:

I have a 'hire date' & a 'term date'. I need to calcuate the difference in
months & don't want to do the calculations manually. EX. 7/1/06 1/1/06 = 6
months

  #17  
Old November 5th, 2009, 12:58 AM posted to microsoft.public.excel.misc
Kenneth Green
external usenet poster
 
Posts: 1
Default How do I create formula to calc difference in dates?

Hi Biff

If I wanted to use a formual to count days including the start date and end
dates what would i use?

e.g days between january 1, 2009 - january 7, 2009 is seven days, but using
the formulas it gives a result of 6 instead of seven

Thanks
Ken
  #18  
Old November 5th, 2009, 01:11 AM posted to microsoft.public.excel.misc
Peo Sjoblom[_3_]
external usenet poster
 
Posts: 137
Default How do I create formula to calc difference in dates?

To me it is only 6 days, how do you get 7?

--


Regards,


Peo Sjoblom


"Kenneth Green" Kenneth wrote in message
...
Hi Biff

If I wanted to use a formual to count days including the start date and
end
dates what would i use?

e.g days between january 1, 2009 - january 7, 2009 is seven days, but
using
the formulas it gives a result of 6 instead of seven

Thanks
Ken



  #19  
Old November 5th, 2009, 01:33 AM posted to microsoft.public.excel.misc
Dave Peterson
external usenet poster
 
Posts: 19,791
Default How do I create formula to calc difference in dates?

You could just add one more to the result:

=a1-a2+1



Kenneth Green wrote:

Hi Biff

If I wanted to use a formual to count days including the start date and end
dates what would i use?

e.g days between january 1, 2009 - january 7, 2009 is seven days, but using
the formulas it gives a result of 6 instead of seven

Thanks
Ken


--

Dave Peterson
  #20  
Old November 5th, 2009, 03:10 PM posted to microsoft.public.excel.misc
Bob I
external usenet poster
 
Posts: 10,698
Default How do I create formula to calc difference in dates?

Subtracting one date from another is always going to give that result.
It's the same as subtracting one number from another. If you want
inclusive, you will have to add one back or subtract the day before the
start day.

Kenneth Green wrote:

Hi Biff

If I wanted to use a formual to count days including the start date and end
dates what would i use?

e.g days between january 1, 2009 - january 7, 2009 is seven days, but using
the formulas it gives a result of 6 instead of seven

Thanks
Ken


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.