Jump to content


Photo

Getting a date from a Memo field


  • Please log in to reply
2 replies to this topic

#1 TheFunkeyGibbon

TheFunkeyGibbon
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 March 2006 - 04:43 PM

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.

RegDate={01/01/2005}

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.


#2 fusionpixel

fusionpixel
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 14 March 2006 - 05:35 PM

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
Did you know there is a manual for PHP? [a href="http://" target="_blank"]http://www.php.net[/a]
Did you know there is a manual for mySQL? [a href="http://" target="_blank"]http://www.mysql.org[/a]

#3 TheFunkeyGibbon

TheFunkeyGibbon
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 15 March 2006 - 10:50 AM

[!--quoteo(post=354957:date=Mar 14 2006, 05:35 PM:name=fusionpixel)--][div class=\'quotetop\']QUOTE(fusionpixel @ Mar 14 2006, 05:35 PM) View Post[/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:

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);

That is a pretty good way of getting what I want.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users