OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to count number of days using calc

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
azrael_demon
General User
General User


Joined: 01 May 2008
Posts: 9

PostPosted: Wed May 07, 2008 6:29 pm    Post subject: How to count number of days using calc Reply with quote

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
View user's profile Send private message
Mr5o1
Power User
Power User


Joined: 05 Dec 2007
Posts: 52

PostPosted: Wed May 07, 2008 7:04 pm    Post subject: Reply with quote

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
Code:

=MONTHS(A1;B1;0)

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
View user's profile Send private message
azrael_demon
General User
General User


Joined: 01 May 2008
Posts: 9

PostPosted: Wed May 07, 2008 10:53 pm    Post subject: How to count number of days using calc Reply with quote

ok but what if the format is in YYYYMMDD, it look like doesnt work pls advise
Back to top
View user's profile Send private message
Mr5o1
Power User
Power User


Joined: 05 Dec 2007
Posts: 52

PostPosted: Thu May 08, 2008 4:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Fri May 09, 2008 3:42 am    Post subject: Reply with quote

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 https://forum.openoffice.org
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group