0

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

Sanjay Rathod
  • 1,083
  • 5
  • 18
  • 45
  • Hello and welcome to stackoverflow. Perhaps you should take some time to review your question in order to explain more clearly your problem and how you have tried to solve it until now. Once done, while waiting for answers you could take a look at http://stackoverflow.com/help/someone-answers to know what you should do when someone answer to your question. – Sylvain Leroux Aug 06 '13 at 13:44

2 Answers2

1

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();
juergen d
  • 201,996
  • 37
  • 293
  • 362
0

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

(see this post for more information.)

jchleb
  • 27
  • 6