Jump to content

Help with Date


honkmaster

Recommended Posts

Hi, i'm trying to change the status column in a table I have based on the last date updated column older than 10 days.

 

This is the query I have so far

 

<?php
date_default_timezone_set('Europe/London');

$now = time();

mysql_connect(localhost,$dbusername,$dbpassword);
@mysql_select_db($db_name) or die( "Unable to select database");
$query="UPDATE contacts
SET status = 'New Prospect'
WHERE status = 'Allocated'
AND  lastupdated < now('d,-10')";
$result=mysql_query($query);

mysql_close();
?>

Link to comment
https://forums.phpfreaks.com/topic/260062-help-with-date/
Share on other sites

Your $now is a variable, but in your mysql syntax, you are missing the $, unless you are trying to use the MySQL function NOW(). If so this might work, but I am not certain NOW() - INTERVAL 10 DAYS. I am not sure if it should be DAY or DAYS, but you can play with it to see if it will work.

Link to comment
https://forums.phpfreaks.com/topic/260062-help-with-date/#findComment-1332978
Share on other sites

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.