CURRENT_TIMESTAMP () inserting zero

1

I am inserting more than 9000 records via query, but the CURRENT_TIMESTAMP () -3 is entering multiple fields with 0000-00-00 00:00:00. Is there any way to prevent this?

INSERT INTO yourls.yourls_url (keyword, url, title, timestamp, ip, clicks) VALUES
('teste', 'meusite.com/teste.htm';, 'Testando o encurtador', CURRENT_TIMESTAMP() -3, '198.xx.xxx.xxx', ''); 
    
asked by anonymous 02.06.2015 / 02:30

1 answer

3

In INSERT it is necessary to show what this -3 means for you can be less 3 hours (Brasilia time) but mysql does not know if it is 3 hours, days, months, years, etc. use subdate to decrease 3 hours from the current date. current_timestamp is synonymous with now ().

INSERT INTO yourls.yourls_url (keyword, url, title, timestamp, ip, clicks)
VALUES
('teste', 'meusite.com/teste.htm', 'Testando o encurtador', SUBDATE(now(), INTERVAL 3 hour), '198.xx.xxx.xxx', '');

Example - sqlfiddle , compare the result of the last two queries they give 3 seconds difference ie you need specify that they are hours as done in the first query.

    
02.06.2015 / 03:17