0

how to check date expiration?

check expire date in mysql database

date------->status
10/27/2010->approve
10/28/2010->approve
10/26/2010->approve

date now is 10/26/2010

so it will search from the table where date=datenow then update the status to finish

2
Contributors
7
Replies
10
Views
6 Years
Discussion Span
Last Post by aizel
0

Is the date still stored as a string or is using a DATE column type in mysql?

UPDATE table SET column = 'finish' WHERE STR_TO_DATE( date, '%m/%d/%Y' )= CUR_DATE()

Something like that would probably work for you, assuming your structure is similar to what it was previously.

Edited by mschroeder: n/a

0

it is a string sir but this

UPDATE table SET column = 'finish' WHERE STR_TO_DATE( date, '%m/%d/%Y )= CUR_DATE()

will update all date that the same with current date but different status.i want to update only the status approve..

1

just add another condition to the query then.

UPDATE table SET column = 'finish' WHERE STR_TO_DATE( date, '%m/%d/%Y' )= CUR_DATE() AND column = 'approve'
Votes + Comments
nicely done
0
UPDATE table SET column = 'finish' WHERE STR_TO_DATE( date, '%m/%d/%Y' )= CURDATE() AND column = 'approve'

thanks sir..
last question how to alert if how many fields where updated

0

sir what if the problem is like this

database

date------->status
10/27/2010->approve
10/28/2010->approve
10/26/2010->approve

form
if he modify the current date to 10/27/2010

this will be the result
date------->status
10/27/2010->finish
10/28/2010->approve
10/26/2010->finish

because this code UPDATE table SET column = 'finish' WHERE STR_TO_DATE( date, '%m/%d/%Y' )= CURDATE() AND column = 'approve' only update the current date like this:
10/27/2010->finish
10/28/2010->approve
10/26/2010->approve

it not update the date exceeded

0

lol i just put < to the current date and it works :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.