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] NOW() not working so good...

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


Joined: 13 Dec 2008
Posts: 6

PostPosted: Wed Jan 11, 2012 3:26 am    Post subject: [SOLVED] NOW() not working so good... Reply with quote

Hi, I have this macro assigned for a button:

[code]

sub ButtonPressed (oEv as object)
dim oForm as object
dim oField as object
dim idate as long
idate=now() -2
oForm = oEv.source.model.parent
oField=oForm.GetByName("datSaapumispvm")
oField.BoundField.value=idate
end sub
[/code]

Date I get from this is two days ahead... so with (-2) I get the right date for the datSaapumispvm. TODAY gives me 1.1.1900, and DATE gives also two days ahead...

Any idea why it is so?? Computer time is right, Windows 7, OpenOffice 3.3.0.

Thanks, Hermanni


Last edited by hzman on Thu Jan 12, 2012 1:14 am; edited 1 time in total
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2696
Location: Apeldoorn, Netherland

PostPosted: Wed Jan 11, 2012 4:02 am    Post subject: Reply with quote

Hello

Maybe this
http://www.oooforum.org/forum/viewtopic.phtml?t=82385&postdays=0&postorder=asc&highlight=sub+date&start=0
can help you.

There you can find different kind of solutions.

Romke
Back to top
View user's profile Send private message
hzman
General User
General User


Joined: 13 Dec 2008
Posts: 6

PostPosted: Wed Jan 11, 2012 7:35 am    Post subject: Not really help. Reply with quote

Hi, thanks for the link, but none that I have tried helps.

If I use idate as STRING then the value of the idate includes "-marks ("11.1.2012"), and it gives me a date 01.01.1800 to datSaapumispvm field. If I use idate as LONG then the value is 11 (today) and it gives me a result of 12.01.1900...

NOW() function gives me a result of 40920 (when idate is LONG), which ends up being 14.1.2012 in datSaapumispvm field, so at the moment 3 days ahead... ????

I have msgbox(idate) in my code so I can see what the idate is before it goes to datSaapumispvm.

Hermanni
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2696
Location: Apeldoorn, Netherland

PostPosted: Wed Jan 11, 2012 9:03 am    Post subject: Reply with quote

Hello

If none of them work I don't have any idea what is wrong.

Romke
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2696
Location: Apeldoorn, Netherland

PostPosted: Wed Jan 11, 2012 9:14 am    Post subject: Reply with quote

Hello

I think you add a value to a date field and it can be better to add a string to the date field. I have learned from Villeroy that there is a different between numbering in date between OOo and what is used in SQL.


Romke
Back to top
View user's profile Send private message
dacm
Super User
Super User


Joined: 07 Jan 2010
Posts: 734

PostPosted: Wed Jan 11, 2012 1:05 pm    Post subject: Reply with quote

See also:
Now() conversions
_________________
Soli Deo gloria
Tutorial: avoiding data loss with Base + Migrating 'Embedded databases'
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2696
Location: Apeldoorn, Netherland

PostPosted: Wed Jan 11, 2012 4:41 pm    Post subject: Reply with quote

Hello

I did place a more clear explanation in the thread.

Romke
Back to top
View user's profile Send private message
dacm
Super User
Super User


Joined: 07 Jan 2010
Posts: 734

PostPosted: Wed Jan 11, 2012 8:13 pm    Post subject: Reply with quote

RPG wrote:
I did place a more clear explanation in the thread...

I presume here: http://www.oooforum.org/forum/viewtopic.phtml?p=463008#463008
_________________
Soli Deo gloria
Tutorial: avoiding data loss with Base + Migrating 'Embedded databases'
Back to top
View user's profile Send private message
hzman
General User
General User


Joined: 13 Dec 2008
Posts: 6

PostPosted: Thu Jan 12, 2012 1:12 am    Post subject: Found another way to do it Reply with quote

I had no idea that you can have a dropdown calender for date-field in a form. Smile

But that does the trick for me. Thanks everyone for good try, none of them worked for me though, or I just didn't know how to make these examples to work.

Hermanni
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