canton Posted December 14, 2010 Share Posted December 14, 2010 Does anyone know how to add 1 year to a timestamp within a field within a given table. here is my very rough query with a wrong syntax but please advise me. Update table SET field DATE_ADD(post_date, INTERVAL 1 YEAR); thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/221593-how-to-add-1-year-to-timestamp/ Share on other sites More sharing options...
requinix Posted December 14, 2010 Share Posted December 14, 2010 Have you heard of this thing called "the assignment operator"? It had its origins in earlier programming languages but has made its way into basically everything you can write in. Sometimes it's written as an "arrow" but the other representation is much more common. Quote Link to comment https://forums.phpfreaks.com/topic/221593-how-to-add-1-year-to-timestamp/#findComment-1147066 Share on other sites More sharing options...
canton Posted December 14, 2010 Author Share Posted December 14, 2010 yes i have seen the problem and have got to the point of this piece of coding --- Update posts SET post_date = post_date + INTERVAL 1 YEAR --- but this NULL the column but have been advised-: "If you have to leave it as an integer, then you're going to have to use FROM_UNIXTIME() to convert the integer into the proper date format, and then UNIX_TIMESTAMP() to convert the newly calculated date value back into an integer for storage." How would i go about doing this? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/221593-how-to-add-1-year-to-timestamp/#findComment-1147068 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.