Page 1 of 1

notify before expiration date

Posted: Tue Mar 15, 2005 5:05 pm
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.

Posted: Tue Mar 15, 2005 5:08 pm
by feyd

notify before expiration date

Posted: Wed Mar 16, 2005 4:16 am
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.

Posted: Wed Mar 16, 2005 4:40 am
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...

Posted: Wed Mar 16, 2005 9:38 am
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.