Jump to content
lauralee

adding an expiration date

Recommended Posts

I have a membership table that includes a field for the date that a membership was added. I want to be able to automatically sort the table by those memberships that have expired after one year from the date the membership was added. Below is the code that lists the members followed by the date of the membership. while ($row = @mysql_fetch_array($result)){ echo '<div class="memberdetails"><span class="second">' . $row['member_name'] . '</span> - ' . $row['membership_date'] . '<br />'; } I'm not sure how to use the ADDDATE function. Please give me a sample of code that would provide an expiration date that is one year after the membership_date.

Share this post


Link to post
Share on other sites

what do you mean by adddate function? are you using timestamp to store register time?

Share this post


Link to post
Share on other sites

what would be more relevant to show us is how the membership date actually gets put into the database in the first place. Depending on the format you are saving it as (ideal would be a timestamp) it could be a simple case of addition, or just some work with the date function. and also as mentioned, what is this adddate function you speak of?

Edited by thescientist

Share this post


Link to post
Share on other sites

ADDDATE() is a mysql function: http://dev.mysql.com...unction_adddate similar to DATE_ADD() it will return the date with a certain amount of time added to it

mysql> SELECT DATE_ADD('2008-01-02', INTERVAL 31 DAY);		-> '2008-02-02'mysql> SELECT ADDDATE('2008-01-02', INTERVAL 31 DAY);		-> '2008-02-02'

edit: so you could use that to determine if that row should expire or display

Edited by astralaaron

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...