MySQL如何向列添加天数

时间:2015-07-09 04:27:10

标签: php mysql

这是我的疑问:

<?=$form->field($model, 'status')->radioList(['1' => 'Approved', '2' => 'Digital', '3' => 'CDP', '4' => 'Print', '5' => 'Other Process', '6' => 'Packing', '7' => 'Dispatch'], ['item' => function($index, $label, $name, $checked, $value) {$checked = $checked == 1 ? 'checked=""' : 'disabled=""';echo "<label><input tabindex='{$index}' type='radio' {$checked}'name='{$name}'value='{$value}'> {$label}</label>";}]);?>

如何为product_created添加天数?

这就是我想要发生的事情SELECT * FROM product WHERE product_created > NOW() ORDER BY product_created DESC

提前致谢..

2 个答案:

答案 0 :(得分:3)

只需使用DATE_ADD,请参阅以下示例:

SELECT * FROM product WHERE DATE_ADD(product_created,INTERVAL 5 DAY)  > NOW() ORDER BY product_created DESC

答案 1 :(得分:2)

您可以使用DATEDIFF

SELECT * FROM product WHERE DATEDIFF(product_created,NOW() >= 5 ORDER BY product_created DESC