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? 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) 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 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?? 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
Archived
This topic is now archived and is closed to further replies.