Jump to content

Getting a date from a Memo field


TheFunkeyGibbon

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/4948-getting-a-date-from-a-memo-field/
Share on other sites

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
[!--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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.