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

[SOLVED] Date String becomes zero

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
Jay Codes
Newbie
Newbie


Joined: 17 Oct 2010
Posts: 4

PostPosted: Mon Oct 18, 2010 10:36 am    Post subject: [SOLVED] Date String becomes zero Reply with quote

I have a text box that fills with Date. The string, however, becomes date 0, when I use

Code:
Form.Columns.getByName("entrydate").updateString(Ctl.text)


0, of course, is 01/01/1800, which appears in the table on the same form when I try to update the 'entrydate' field and 'Ctl.text' is the string contents of the text box, where the date is correct.

When I manually enter the date 10/18/2010, of course, it is correct in that column.

When I fill a text box with a string, the column of the table containing string data updates fine.

The data type of the column, entrydate, in the table is date.

Does the string need to be converted to a date integer? And if so, is there a different method besides .updateString() that will apply it to that column?


Last edited by Jay Codes on Tue Oct 19, 2010 12:31 pm; edited 1 time in total
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10065
Location: Germany

PostPosted: Mon Oct 18, 2010 12:52 pm    Post subject: Reply with quote

x.updateString(blah) may work with a date field if and only if the string is in ISO format.
Otherwise you use a date struct and x.updateDate(com.sun.star.util.Date)
_________________
Rest in peace, oooforum.org
Get help on http://forum.openoffice.org
Back to top
View user's profile Send private message
Jay Codes
Newbie
Newbie


Joined: 17 Oct 2010
Posts: 4

PostPosted: Tue Oct 19, 2010 12:31 pm    Post subject: Reply with quote

x.updatestring didn't work. It entered 0, same as when I converted date to int. But converting date to single did give me 40479, which is the date code. But that didn't go in there either.

I didn't know how to do a struct, and x.updateDate(com.sun.start.util.Date) literally didn't work either, and I figured it wasn't meant literally, so I googled com.sun.star.util and found the oobase docs saying it was a structure, but no info on how to do it. http://api.openoffice.org/docs/common/ref/com/sun/star/util/Date.html

Also looked up ISO date format... http://en.wikipedia.org/wiki/ISO_8601

Next I found a web archived mailing list response from Drew Jensen and he has functions to form the struc.

http://www.mail-archive.com/users@dba.openoffice.org/msg03282.html

Here is what worked.

mine, with Villeroy's, x.updateDate(), which I wasn't aware of either....
Code:
Form.Columns.GetByName("entrydate").updateDate( DateTodbDate( NOW ) )


from D.J.
Code:
function DateTodbDate( aDate as date )
   dim dbDate as new com.sun.star.util.Date
dbDate.Month = Month( aDate )
   dbDate.Day = Day( aDate )
   dbDate.Year = Year( aDate )
dateTodbDate = dbDate


Thanks for the reply, Villeroy. - J
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 Base 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