dennismonsewicz Posted September 11, 2008 Share Posted September 11, 2008 Is there a way to record a time stamp and date stamp in a mysql db and have it become static once the row has been created and then if a user updates that particular row have another column change according to when the user changed the information? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2008 Share Posted September 11, 2008 use 2 timestamp fields, setting one of them to ON UPDATE CURRENT_TIMESTAMP. on insert, set both to NOW(), then the one with ON UPDATE will automatically update whenever the record is updated. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted September 11, 2008 Author Share Posted September 11, 2008 can you give me an example using the now() function? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2008 Share Posted September 11, 2008 UPDATE some_table SET some_date_field = NOW() Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted September 11, 2008 Author Share Posted September 11, 2008 ah gotcha, I will give that a try, thanks Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted September 11, 2008 Author Share Posted September 11, 2008 i am using php myadmin to create a datetime field and when i tell it to on update current_timestamp and I am receiving an error: #1294 - Invalid ON UPDATE clause for 'update_date' column Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted September 11, 2008 Author Share Posted September 11, 2008 problem solved you have to place the current timestamp on_update field first Quote Link to comment 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.