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
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
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.