Hello everybody!!
Can I create a field that automatically stamps the current date without code?
I have looked for information about it, and I see that code is used. There is no sensible way to do it? I have seen the CURDATE () function, but I would not know how to use it to be inserted automatically in a Date field of a table, every time I create a new record.
Thank you!
Dreamer.-
[Solved] Create field that automatic stamps Current Date?
-
- Posts: 17
- Joined: Sun May 20, 2018 12:02 am
[Solved] Create field that automatic stamps Current Date?
Last edited by DreamerArgentino on Tue May 22, 2018 4:39 am, edited 1 time in total.
OpenOffice 4.1.5 On Windows 10
-
- Volunteer
- Posts: 1547
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Create field that automatically stamps the current date?
To add a Timestamp column that
and then got to Tools->SQL and execute the command.
You should also select View->Refresh tables to make sure you can see the change to your table.
edit the following SQL command with your table and column/field namesautomatically stamps the current date without code
Code: Select all
ALTER TABLE "YourTableName" ADD COLUMN "YourColumnName" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP;
You should also select View->Refresh tables to make sure you can see the change to your table.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
-
- Posts: 17
- Joined: Sun May 20, 2018 12:02 am
Re: Create field that automatically stamps the current date?
It works wonders! but, I ask, will it be possible to generate two separate fields in the same way? One Date and another Time? Thanks!UnklDonald418 wrote:To add a Timestamp column thatedit the following SQL command with your table and column/field namesautomatically stamps the current date without codeand then got to Tools->SQL and execute the command.Code: Select all
ALTER TABLE "YourTableName" ADD COLUMN "YourColumnName" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP;
You should also select View->Refresh tables to make sure you can see the change to your table.
OpenOffice 4.1.5 On Windows 10
-
- Volunteer
- Posts: 1547
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Create field that automatically stamps the current date?
You can add separate Date and Time controls to a form using the TimeStamp column as the Data source.
One way to separate them in a query use
If you don't need all the time accuracy you could change the time formatting to 'HH24:MI' or maybe 'HH12:MI'
One way to separate them in a query use
Code: Select all
TO_CHAR("YourTimeStampColumnName", 'MM/DD/YYYY') AS "Date",
TO_CHAR("YourTimeStampColumnName", 'HH24:MI:SS:FF') AS "Time"
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Re: Create field that automatically stamps the current date?
DreamerArgentino wrote:It works wonders! but, I ask, will it be possible to generate two separate fields in the same way? One Date and another Time? Thanks!
Code: Select all
-- Code below will add a DATE column and a DEFAULT DATE . . . change both table and column name to your needs
ALTER TABLE "YourTableName" ADD COLUMN "YourDateColumnName" DATE DEFAULT CURRENT_DATE;
-- Code below will add a TIME column and a DEFAULT TIME . . . change both table and column name to your needs
ALTER TABLE "YourTableName" ADD COLUMN "YourTimeColumnName" TIME DEFAULT CURRENT_TIME;
-- Code below will add a TIMESTAMP column and a DEFAULT TIMESTAMP . . . change both table and column name to your needs
ALTER TABLE "YourTableName" ADD COLUMN "YourTimeStampColumnName" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP;
-
- Posts: 17
- Joined: Sun May 20, 2018 12:02 am
Re: Create field that automatically stamps the current date?
Excellent!! Thank you very much to all!!!Sliderule wrote:DreamerArgentino wrote:It works wonders! but, I ask, will it be possible to generate two separate fields in the same way? One Date and another Time? Thanks!SlideruleCode: Select all
-- Code below will add a DATE column and a DEFAULT DATE . . . change both table and column name to your needs ALTER TABLE "YourTableName" ADD COLUMN "YourDateColumnName" DATE DEFAULT CURRENT_DATE; -- Code below will add a TIME column and a DEFAULT TIME . . . change both table and column name to your needs ALTER TABLE "YourTableName" ADD COLUMN "YourTimeColumnName" TIME DEFAULT CURRENT_TIME; -- Code below will add a TIMESTAMP column and a DEFAULT TIMESTAMP . . . change both table and column name to your needs ALTER TABLE "YourTableName" ADD COLUMN "YourTimeStampColumnName" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP;
Greetings!
DreamerArg.-
OpenOffice 4.1.5 On Windows 10