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

getdate() question

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
eduzs
OOo Advocate
OOo Advocate


Joined: 07 Feb 2005
Posts: 356
Location: RJ, BRAZIL

PostPosted: Tue Aug 30, 2005 7:38 am    Post subject: getdate() question Reply with quote

How do I get a date in a calc spreadsheet cell??? I try .getdate() but is wrong.

I want to get date as I easy can get value with .getvalue() and text with .gettext().

Thanx
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Tue Aug 30, 2005 9:44 am    Post subject: Reply with quote

there is no such thing as dates in calc cells, only doubles or strings. There maybe a double in a calc cell, which is formatted as a date, however. With getValue you get the double, and it does not matter if the double is shown formatted as a double, or shown formatted as a date.

For a double representing a date, the part before the decimal point can be interpreted as the numer of days since 1899, Dec 30 (?), and the part after the point as a the fraction of the actual day.

Hope that helps a bit,

ms777
Back to top
View user's profile Send private message
DrewJensen
Super User
Super User


Joined: 06 Jul 2005
Posts: 2616
Location: Cumberland, MD

PostPosted: Tue Aug 30, 2005 10:59 am    Post subject: Reply with quote

If you want a date you can always convert the value to a dat with CDate

Say I have a dateforfmated cell as A1 Sheet 1, which is really just a cell with a double.

Code:

Sub Main
Dim Doc As Object
Dim Sheet As Object
Dim Cell As Object

Doc = StarDesktop.CurrentComponent
Sheet = Doc. Sheets (0)
Cell = Sheet.getCellByPosition(0, 0)

if Cell.Type = com.sun.star.table.CellContentType.VALUE then
   print CDate( Cell.Value )
   endif

End Sub


of course you can just use

yourDateVariable = CDate( Cell.Value)

HTH

Drew Jensen
_________________
Blog - http://baseanswers.spaces.live.com/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API 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