LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can I get an automatic date field on my Libreoffice Base file? (https://www.linuxquestions.org/questions/linux-software-2/how-can-i-get-an-automatic-date-field-on-my-libreoffice-base-file-4175646134/)

mark_alfred 01-13-2019 04:31 PM

How can I get an automatic date field on my Libreoffice Base file?
 
Hello. I created a diary in Libreoffice Base. It has four fields, those being ID, Date, Title, Entry. The ID field is a primary key field that is automatically created, and its field type is "Integer [INTEGER]". The date field is manually entered by me (which I hope to change to being created automatically) and its field type is "Date/Time [TIMESTAMP]". The other two are text fields.

Info:
I use Debian 9 (stable), and I use Libreoffice Version: 5.2.7.2
Build ID: 1:5.2.7-1+deb9u4. I have both OpenJDK 1.7 and 1.8 installed (I needed to install and enable 1.7 to be able to update my older LineageOS phone, though I've set LO to use 1.8 --> perhaps I need to change this to 1.7).

Efforts so far:
I tried searching for an answer to this and found the following: https://ask.libreoffice.org/en/quest...ction-in-base/

The suggestion there was to "place a Text box where you want the date. Then in the fields' Data tab set as follows" ... select the option of TODAY() for it. I was unable to find that option after setting up a text box. The only options were to link to existing fields, so I linked to the date field and basically had an echo of this. Thus, not a solution.

I also tried the option of Insert/Field/Date, but that didn't work.

All ideas appreciated.

Corvette 01-13-2019 05:39 PM

Try using SQL directly (Tools -> SQL in the main window) and executing a statement like this:

PHP Code:

ALTER TABLE my_table ALTER COLUMN date SET DEFAULT CURRENT_DATE 

See the following: https://ask.libreoffice.org/en/quest...tabase-record/

mark_alfred 01-13-2019 11:32 PM

1 Attachment(s)
[new edit]
Okay, this works perfect! Below I had an error because the old date field was deemed mandatory, which produced the error. But, since I've now got two new automatic fields for date and time, I no longer need the old date field.

Thanks again!

[prior post]
Thanks for your response Corvette. I tried what was written, but it did not work. I created two fields for both time and date. Then, for each, I used the "Tools -> SQL" function from the main window, enter the commands (adjusted for the naming of my file/fields). The commands were accepted. However, in attempting to create a new post in the diary, in a new form that had these two fields, it gave me the following error (see picture).


All times are GMT -5. The time now is 10:21 AM.