Frage

I have a database with 30k+ users. I wish to add 4 days to a time I have stored for each user in unixtimestamp.

The time represent when they have joined, therefore each timestamp is different than the other.

Can I, simply, add 4 days to ALL of these timestamp via. SQL?

War es hilfreich?

Lösung

Yes you can

UPDATE yourtable SET yourfield = yourfield + 345600

or you calculate it directly in your query.

UPDATE yourtable SET yourfield = yourfield + (60*60*24*4)

But you should make some tests before.

Andere Tipps

Try with INTERVAL 4 DAYS like this

UPDATE tbl_name set time_col = DATE_ADD(time_col, INTERVAL 4 DAY);

You do it using single UPDATE query. Try this

UPDATE `users` SET time = time+(86400*4);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top