I am trying to create a table that has date and time columns used to store the date and time information when the entry is recorded in the database. In the MySQL documentati
CREATE TABLE t1 (
ts TIME,
dt DATE
);
Only a timestamp field can have DEFAULT CURRENT_TIMESTAMP. It contains both a date and time. TIME and DATE fields will need to be set by your application.
There is no point in having separate columns for Date and Time. It does not make much sense
You can create the table like this
CREATE TABLE timeDate (
id INT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
);
And if you want the Date part use this query
SELECT DATE(`ts`) FROM timedate WHERE id =someId
And if you want the Time part use this query
SELECT TIME(`ts`) FROM timedate WHERE id =someId