Insert the current date and current time into a new database record?

I want to have the current date and time inserted into separate fields in a database record when a new record is written. How do I do this?

Thanks in advance!

You will need first to have (or create) SEPARATE columns for Date (must be ‘Date’ type) and Time (must be ‘Time’ type) in your table - I’m calling your table Dates_Times but you will need to change it to whatever you have called it in the code below. Then you have to set the defaults for each of these columns by running each of the two SQL statements below (separately) from the SQL window (menu: TOOLS>SQL):

ALTER TABLE "Dates_Times" ALTER COLUMN "Date" SET DEFAULT CURRENT_DATE
ALTER TABLE "Dates_Times" ALTER COLUMN "Time" SET DEFAULT CURRENT_TIME

You should see a “Command successfully executed” message after each command is run.

Then, every time you add a new record, the current values of Date and Time will be added (you might need to ‘refresh’ the table to see them). However note, the date and time values will NOT be updated whenever you update a particular row/record (that’s a different problem).

Thank you very much!

I really appreciate your consise answer to the question above. I had the same current-date question. After inserting the first line of SQL above, the current date appeared upon entering a new record in the table.

Hoping to be able to contribute toward the “answer” portion of this website someday, I will use this site and look for your answers to BASE questions as I go through the process of learning a data base system after years of spreadsheet dependence in our family business.