TheFunkeyGibbon Posted March 14, 2006 Share Posted March 14, 2006 Firstly thanks for any help offered!Now down to business.I am trying to select a date from a memo field where it is preceded by some identifying text e.g.[i]RegDate={01/01/2005}[/i]However there is a lot of other data in the memo too. It's been used as a sort of custom field for the user to add custom database fields (don't ask... :roll: ).What I need to do is get out the date part of that italic text above and convert it into a date that I can use to calculate the date between that date and another one (one that is sensibly stored as a date in the db).The database (MySQL) isn't mine. So I can't change anything to do with it.Please ask if this doesn't make sense, it really is at the limits of my MySQL and PHP understanding. Quote Link to comment Share on other sites More sharing options...
fusionpixel Posted March 14, 2006 Share Posted March 14, 2006 One solution might be using a regular expression that pulls out the date.check out this tutorial:[a href=\"http://weblogtoolscollection.com/regex/regex.php\" target=\"_blank\"]http://weblogtoolscollection.com/regex/regex.php[/a]Now... there might be more ways to do it, but that could be one.good luck Quote Link to comment Share on other sites More sharing options...
TheFunkeyGibbon Posted March 15, 2006 Author Share Posted March 15, 2006 [!--quoteo(post=354957:date=Mar 14 2006, 05:35 PM:name=fusionpixel)--][div class=\'quotetop\']QUOTE(fusionpixel @ Mar 14 2006, 05:35 PM) [snapback]354957[/snapback][/div][div class=\'quotemain\'][!--quotec--]One solution might be using a regular expression that pulls out the date.check out this tutorial:[a href=\"http://weblogtoolscollection.com/regex/regex.php\" target=\"_blank\"]http://weblogtoolscollection.com/regex/regex.php[/a]Now... there might be more ways to do it, but that could be one.good luck[/quote]Thanks. I thought I'd let you know I'd found this:[code]function remover($string, $sep1, $sep2){ $string = substr($string, 0, strpos($string,$sep2)); $string = substr(strstr($string, $sep1), 1); return $string;}$string = "Some text (some note) some other text";$str1 = "(";$str2 = ")";echo remover($string, $str1, $str2);[/code]That is a pretty good way of getting what I want. Quote Link to comment 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.