J
J
jydna2017-01-12 18:26:22
MySQL
jydna, 2017-01-12 18:26:22

How to change unix time in a column with step +1 from the previous line?

It was necessary to change the "date/time" values ​​so that in each subsequent line they differed from the previous line by a random one from 4 hours to two days. The value of the first line is set.
Tell me how to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-01-12
@qonand

in each subsequent line differed from the previous line

it all depends on what criteria determines the previous line. In general, you can do something like this:
// устанавливаем стартовую дату
SET @dt := TIMESTAMP('2017-01-01'); 
// обновляем данные
UPDATE tablename SET fieldname = (select @dt:= @dt + INTERVAL 1 DAY);

+ INTERVAL 1 DAY, respectively, replace with the interval you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question