notify before expiration date

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Think Pink
Forum Contributor
Posts: 106
Joined: Mon Aug 02, 2004 3:29 pm

notify before expiration date

Post by Think Pink »

hello,
pls help with the folloeing.
I have a table
[users]
id
user_name
date_added
exp_date


the problem is like this:
let's say I add a new user and he's expiration date is 1 year after the day he was added.
In notify.php i want to display the users that there expiration date is in less that 7 days from today's date, because I want to be able to contact them and tell them that they should log in again or something like this.

I know how to display the users in notify.php that have the today() date equal with the expiration date but this doesn't makes me happy.

this should be something like this:
select * from users where ((exp_date - date()) < 7).

I know i didn't explain my self to clear, but i hope you understand.
thx.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
Think Pink
Forum Contributor
Posts: 106
Joined: Mon Aug 02, 2004 3:29 pm

notify before expiration date

Post by Think Pink »

thx,
but it seems to me that nothing is working. I have the exact problem the guy that started the topic you showed me.

datediff was added in a newer version of mysql that the server has.
and i tried using date_sub, and other functions, but no use. And belive me i read the manual befor posting here.

do you think there is another solution? other than upgrading the mysql.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

you could do it a different way (longer way but works).

by creating 3 fields...

one field = date to which it was added
second field = date on which to notify.
third field = date of termination.

then you just have to check to see when/if toda's date ever equals the second field or whatever and you can then notify the user...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

at the very least, converting them down to unix timestamps, finding the difference and brining that info back to number of days should work without problem. Unless your database is incapable of converting the date supplied, in which case I'd have to ask for a table structure export.
Post Reply