Base - populate a date field and a time field with "now"

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

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.

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.