| View previous topic :: View next topic |
| Author |
Message |
eduzs OOo Advocate


Joined: 07 Feb 2005 Posts: 356 Location: RJ, BRAZIL
|
Posted: Tue Aug 30, 2005 7:38 am Post subject: getdate() question |
|
|
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 |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Tue Aug 30, 2005 9:44 am Post subject: |
|
|
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 |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
Posted: Tue Aug 30, 2005 10:59 am Post subject: |
|
|
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 |
|
 |
|