adrianle Posted March 16, 2015 Share Posted March 16, 2015 I'm coding in PHP/mySQLi and I need to learn how to take date from one field, time from another field, and insert them into a single datetime column on my database. Can't seem to find a reference on how to do this. Suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/295296-inserting-date-time-from-two-fields-into-one-column/ Share on other sites More sharing options...
Barand Posted March 16, 2015 Share Posted March 16, 2015 if the fields are in correct formats (yyyy-mm-dd and hh:ii:ss) then UPDATE mytable SET datetime = CONCAT(date, ' ', time) 1 Quote Link to comment https://forums.phpfreaks.com/topic/295296-inserting-date-time-from-two-fields-into-one-column/#findComment-1508255 Share on other sites More sharing options...
adrianle Posted March 16, 2015 Author Share Posted March 16, 2015 I completely forgot about the concat function.. thanks so much Quote Link to comment https://forums.phpfreaks.com/topic/295296-inserting-date-time-from-two-fields-into-one-column/#findComment-1508264 Share on other sites More sharing options...
adrianle Posted March 17, 2015 Author Share Posted March 17, 2015 if the fields are in correct formats (yyyy-mm-dd and hh:ii:ss) then UPDATE mytable SET datetime = CONCAT(date, ' ', time) I could use this same function in an INSERT as well.. will anything much change in that case?? Quote Link to comment https://forums.phpfreaks.com/topic/295296-inserting-date-time-from-two-fields-into-one-column/#findComment-1508267 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.