koolgirl Posted June 17, 2006 Share Posted June 17, 2006 Hi,I have over 2000 records in the database for the site visitors. I was keeping the Time and Date in a field type "datetime" and the NOW() statement in php script was updating this field. So in all those records I have the time and date stored in "0000-00-00 00:00:00" format. Yes, I know this was a little stupid but I was new. Now I want to save Date and Time seperately in two different fields. I can do that for the new records but my question is that is it possible to split the past records too with one query without having to edit the fieilds one by one in a way that after executing the query all the records in "datetime" field get split and get stored in the same order into the two new fields for date and time?I know this is not simple and am not really expecting an easy solution, although I have been getting perfect help from this forum.Many Thanks in advance [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/12252-date-time-seperation/ Share on other sites More sharing options...
redarrow Posted June 17, 2006 Share Posted June 17, 2006 I want to also know how this can be done,what do you do, would you extract all the old values then split them and then insert them via the users id dont no but very intresting. Quote Link to comment https://forums.phpfreaks.com/topic/12252-date-time-seperation/#findComment-46722 Share on other sites More sharing options...
Fyorl Posted June 17, 2006 Share Posted June 17, 2006 Why split them? My web app also uses that but there's no need to split the values when you can get the date and time from one value instead of two. Here's a function I use:[code]function datetostr($datetime) { return gmdate("jS F Y", strtotime($datetime)); }[/code]You could do the same to get any value like: date("d", strtotime($datetime)); to get the day. Just lookup the date() function and then you can use that to grab any value you want from the one stored in your database. Quote Link to comment https://forums.phpfreaks.com/topic/12252-date-time-seperation/#findComment-46831 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.