Sanjay Rathod
Sanjay Rathod

Reputation: 1143

How can i add date as auto update when import data from csv file?

I want to add date and time auto update. Can anyone help me how can i do this. i am importing data from csv file and there is no any field of date i want to auto update this field in database when each data inserted through csv file. please help

Upvotes: 0

Views: 1174

Answers (2)

jchleb
jchleb

Reputation: 27

Sanjay Rathod --> UPDATE [yourTable] SET [yourDatetimeColumn] = NOW();

(see this post for more information.)

Upvotes: 0

juergen d
juergen d

Reputation: 204894

Just add a NOW() for that field.

Or if you have two seperate columns for date and time then you can use the build-in functions CURDATE() and TIME().

Example:

LOAD DATA INFILE 'data.csv'
INTO TABLE t1
(column1, col2, col3)
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n'
SET date_time_field = NOW();

Upvotes: 1

Related Questions