cgchris99 Posted June 14, 2003 Share Posted June 14, 2003 I have a database that has the following fields month (in long format like July) dayofmonth year I need to create an update script that will take these three fields and give me a mysql date field. Can anyone help with this? Thanks Link to comment https://forums.phpfreaks.com/topic/592-help-concatenating-date-fields-into-real-date-field/ Share on other sites More sharing options...
holiks Posted June 16, 2003 Share Posted June 16, 2003 any specific reason to use 3 fields? why not just use one? e.g \"date_field DATETIME\" or maybe \"date_field TIMESTAMP\" ..date maniupualtion would be easier i think Link to comment https://forums.phpfreaks.com/topic/592-help-concatenating-date-fields-into-real-date-field/#findComment-2003 Share on other sites More sharing options...
cgchris99 Posted June 16, 2003 Author Share Posted June 16, 2003 I agree that one field is better. But for some strange reason it wasn\'t designed that way. But now is has one field. Thanks Link to comment https://forums.phpfreaks.com/topic/592-help-concatenating-date-fields-into-real-date-field/#findComment-2004 Share on other sites More sharing options...
pallevillesen Posted June 16, 2003 Share Posted June 16, 2003 concat ? P. concat(year,\'-\',month,\'-\',dayofmonth); You can rewrite the long format to numeric format using the case: (CASE month WHEN \'January\' THEN 1 WHEN \'February\' THEN 2 .... THEN 12 END) as month_numeric; So you\'ll end up with: concat(year,\'-\', (CASE month WHEN \'January\' THEN 1 WHEN \'February\' THEN 2 .... THEN 12 END),\'-\', dayofmonth); P. Link to comment https://forums.phpfreaks.com/topic/592-help-concatenating-date-fields-into-real-date-field/#findComment-2009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.