4 sty 2013

Zamiana przecinka na spacje przy użyciu regexp_replace

select
  a_title,
  regexp_replace(a_title, ' +', ' ', 'g')
from articles
where
  a_status = 't'
  and a_title ~ ' '
update articles
set
  a_title = regexp_replace(a_title, ',', ' ')
where
  a_status = 't'
  and a_title ~ ','
update articles
set
  a_title = regexp_replace(a_title, ' +', ' ', 'g')
where
  a_status = 't'
  and a_title ~ ' '
11 sie 2010

Operacje na datach przy wykorzystaniu date_trunc

select czas, date_trunc('day', czas)+'15:59:12' as czas2 from czas limit 1;
UPDATE czas set czas = date_trunc('day', czas)+'15:59:12' WHERE wt_id = 3850;

"2008-11-07 15:58:37";"2008-11-07 15:59:12"

select
  czas, date_trunc('day', czas), date_trunc('day', timestamp '2010-08-11')
from
  czas_t
where
  date_trunc('day', czas) = date_trunc('day', timestamp '2010-08-11')

"2010-08-11 07:37:46";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 07:40:49";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 08:04:42";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 09:12:32";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 08:55:52";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 15:59:12";"2010-08-11 00:00:00";"2010-08-11 00:00:00"