23 kwi 2010

Zapytanie o rekordy z dnia bieżącego + jeden dzień

select NOW()::date "2010-04-23"

select t_date from table where t_date >= NOW()::date+'1 day'::interval order by t_date limit 3

"2010-04-24"
"2010-04-24"
"2010-04-24"

select t_date from table where t_date >= NOW()+'1 day'::interval order by t_date limit 3

"2010-04-25"
"2010-04-25"
"2010-04-25"

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