| View previous topic :: View next topic |
| Author |
Message |
azrael_demon General User

Joined: 01 May 2008 Posts: 9
|
Posted: Wed May 07, 2008 6:29 pm Post subject: How to count number of days using calc |
|
|
Hi
i got one problem, i wish to count the number of days using calc but i dont know can, there is an example: "25/04/1999 19/09/2004" using this two date i want to know how many days and/or month are there?
Thanks |
|
| Back to top |
|
 |
Mr5o1 Power User

Joined: 05 Dec 2007 Posts: 52
|
Posted: Wed May 07, 2008 7:04 pm Post subject: |
|
|
Firstly, is that two date string contained in -one- cell? or two different ones? if its one cell, you'll first need to split them in two, using LEFT and RIGHT functions (assuming the date formats will always be the same, otherwise it can still be done but is a little more complicated)
Once they're in seperate cells.. lets say:
A1: 25/04/1999
B1: 19/09/2004
then you could use the following in C1 to calculate the # of months
and the following in D1 to calculate the # of days
| Code: |
=(EOMONTH(A1;0)-A1)+(B1-EOMONTH(A1;D1))
|
Hope this helps! |
|
| Back to top |
|
 |
azrael_demon General User

Joined: 01 May 2008 Posts: 9
|
Posted: Wed May 07, 2008 10:53 pm Post subject: How to count number of days using calc |
|
|
| ok but what if the format is in YYYYMMDD, it look like doesnt work pls advise |
|
| Back to top |
|
 |
Mr5o1 Power User

Joined: 05 Dec 2007 Posts: 52
|
Posted: Thu May 08, 2008 4:51 pm Post subject: |
|
|
sorry... my bad, should be:
| Code: |
=(EOMONTH(A1;0)-A1)+(B1-EOMONTH(A1;C1))
|
the second EOMONTH should be A1;C1 not A1;D1 like I listed before.. the second field should be the number of months we calculated with the months function. sorry about that...
I tried it with YYYYMMDD (and YYYY-MM-DD in case thats what you meant?) and it works fine, so long as the two date cells are formatted appropriately, and C1 & D1 are formatted as numbers. |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Fri May 09, 2008 3:42 am Post subject: |
|
|
Two dates in A1 and B1 you get the difference by substracting one from the other
=B1-A1 or =A1-B1 respectively.
Dates are nothing but specially formatted number in unit "Days".
Get the hours:
=(B1-A1)*24 _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
|