12 Mar 2010

Zapytanie do bazy z wykorzystaniem funkcji NOW()

SELECT * FROM TABLE WHERE t_add_date < NOW()-'5 MONTH'::INTERVAL
SELECT * FROM TABLE WHERE t_add_date < NOW()+'5 MONTH'::INTERVAL
SELECT * FROM TABLE WHERE t_add_date < NOW()-'1 DAY'::INTERVAL
SELECT * FROM TABLE WHERE t_add_date < NOW()-'2 DAYS'::INTERVAL
SELECT * FROM TABLE WHERE t_add_date < NOW()-'1 DAY'::INTERVAL
SELECT * FROM TABLE WHERE t_add_date < NOW()-'5 MINUTES'::INTERVAL
SELECT * FROM TABLE WHERE t_add_date < NOW()-'3 HOURS'::INTERVAL
23 Lip 2009

Dodanie do daty akutalnej godziny

echo date('H:i:s', strtotime('now')) . ' ';
echo date('Y-m-d', strtotime("+2 days")) . ' ' . date('H:i:s', strtotime('now')) . '';
$task_dateend = date('Y-m-d H:i:s', strtotime(date('Y-m-d', strtotime("+2 days")) . ' ' . date('H:i:s', strtotime('now'))));
echo $task_dateend;

Wynki:
2009-07-25 14:02:51