Jump to content

if CURDATE(),INTERVAL 30 DAY


adzie

Recommended Posts

Hello folks,

 

Can anyone tell me whats wrong with this below.  every entry shows as either expired or current but each row should show different answer.  I want to show expired if $aarrep['1'] date is greater than 30 days.

 

if ("DATE_SUB(CURDATE(),INTERVAL 30 DAY)" >= $aarrep['1'])
{
$status = "Expired";
}
else
{
$status = "Valid";
}

Link to comment
https://forums.phpfreaks.com/topic/168340-if-curdateinterval-30-day/
Share on other sites

That syntax most closely resembles SQL but that is not an SQL query or SQL if() logic, so you would need to show the context of how you are using that in your query and the double-quotes in the vicinity of the DATE_SUB() function are making it into a string, so it will be a little hard to compare the string "DATE_SUB(CURDATE(),INTERVAL 30 DAY)" with a value in $aarrep['1']

 

DATE_SUB() is a mysql function. It is used in a mysql query, not in php logic.

 

Edit: And the php date_sub() function has a significantly different syntax.

PFMaBiSmAd ,

 

Thanks for your advice.

 

$aarrep[1']  gives me the date for the user in 2009-07-31.

 

What I need to do is find out if that date is more than 28 days from today and either print expired or print valid.

 

I have tried many different examples and none give me the result I'm looking for.

 

What would be a correct route to follow.

 

many thanks

 

 

Archived

This topic is now archived and is closed to further replies.

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