bubblegum.anarchy Posted April 13, 2007 Share Posted April 13, 2007 Hi Everyone! Here is what I am trying to do (using mysql only): Convert the following strings: Second Monday March Second Monday June First Tuesday November Last Thursday August to their respective mysql dates. SET @date_string := 'Second Monday March'; SELECT MYSQLCODEGENUIS(@date_string); Quote Link to comment https://forums.phpfreaks.com/topic/46794-date-extraction/ Share on other sites More sharing options...
artacus Posted April 13, 2007 Share Posted April 13, 2007 I don't think you'll be able to do that cleanly in mysql. You should have pretty good luck with php's strtotime() Quote Link to comment https://forums.phpfreaks.com/topic/46794-date-extraction/#findComment-228135 Share on other sites More sharing options...
bubblegum.anarchy Posted April 13, 2007 Author Share Posted April 13, 2007 The strtotime function was what the database values were designed for but I am now required to have the conversion performed directly in the sql query - I will have to try and find the code for the PHP strtotime function if an answer is not posted. Quote Link to comment https://forums.phpfreaks.com/topic/46794-date-extraction/#findComment-228164 Share on other sites More sharing options...
artacus Posted April 13, 2007 Share Posted April 13, 2007 Well what you'd typically do is have php convert it into an actual time then store it as a data or datetime in mysql. If you really really have to store the strings, use two fields, one for the date and the other for the string. Quote Link to comment https://forums.phpfreaks.com/topic/46794-date-extraction/#findComment-228171 Share on other sites More sharing options...
fenway Posted April 13, 2007 Share Posted April 13, 2007 Provided that you can store this string somewhere, you could split it into three parts, and then figure out how to piece it back together in the DB.q Quote Link to comment https://forums.phpfreaks.com/topic/46794-date-extraction/#findComment-228426 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.