Ask Your Question
1

Base - populate a date field and a time field with "now" [closed]

asked 2014-06-07 22:21:55 +0100

Göstapopoulos gravatar image

updated 2014-06-07 22:24:54 +0100

In my form i want a date field and a time field to be populated with current date and time as default. How do i do that?

Then i have a second datetime field. In the form i want to have a text field (or a dropdown maybe) in which i type in a time differens in minutes, in relation to the first field, and the result to be stored in the second datetime field.

That sounds messy, here's and example:

First datetime field: 2014-06-07 23:00
Text field: 10 (this is a time differens in minutes)
Result stored in second datetime field in the db table: 2014-06-07 22:50

Does it make any sense?

Should i be considering another db backend instead of the standard one in base when dealing with different timestamps? Like "created at", "updated at" and so on?

Thanks! /Göstapopoulos

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-02-25 00:21:43.580235

Comments

I sure wish that so many of these questions and answers weren't closed. I have other similar questions, and think there are other answers to this possibly.

EasyTrieve gravatar imageEasyTrieve ( 2016-11-02 09:59:40 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2014-06-08 00:46:28 +0100

frofa gravatar image

updated 2014-06-09 00:40:38 +0100

In my form i want a date field and a time field to be populated with current date and time as default. How do i do that?

See this answer.

Then i have a second datetime field. In the form i want to have a text field (or a dropdown maybe) in which i type in a time difference in minutes, in relation to the first field, and the result to be stored in the second datetime field.

Sounds like you will need a macro (basic code) or a trigger (SQL code) which executes when you enter your 'time difference' data to compute the contents of the second datetime field. The SQL solution would use TIMESTAMPADD - see HERE.

Unfortunately, some of the above SQL functions are not available in the default database engine HSQLDB version 1.8 used by Base - see HERE - so you'll need to upgrade your setup to use the current HSQLDB v.2.x in a 'split' mode configuration - see THIS TUTORIAL on how to do it. Note: there is a macro given in the second-last reference that might be able to be modified to do what you want under the default database engine.

One final point; you don't necessarily need to update your table to actually store the new calculated timestamp. You could just display it in a result-set using a query (i.e. SELECT statement) incorporating the TIMESTAMPADD function to compute the new datetime value.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-06-07 22:21:55 +0100

Seen: 2,540 times

Last updated: Jun 09 '14