« February 2013 | Main | October 2013 »

March 08, 2013

Update one table from another

-- UG only
update dss_chapuza.proposal set proposal_title = tc.new_title from 
dss_marking.ug_title_change_feeder tc where tc.proposal_id = proposal.proposal_id

Posted by pj at 01:06 PM | Comments (0)

March 07, 2013

Get BST dates in PostgreSQL

select 
date_trunc('month', (extract('year' from now()::timestamp)::text||'-03-01 00:00:00 GMT'::text)::timestamp + '1 month'::interval) - '1 day'::interval + (((1 - 7 - to_char(date_trunc('month', (extract('year' from now()::timestamp)::text||'-03-01 00:00:00 GMT'::text)::timestamp + '1 month'::interval) - '1 day'::interval,'D')::int) %7)||' days')::interval 
as last_sunday_march, 
date_trunc('month', (extract('year' from now()::timestamp)::text||'-10-01 00:00:00 GMT'::text)::timestamp + '1 month'::interval) - '1 day'::interval + (((1 - 7 - to_char(date_trunc('month', (extract('year' from now()::timestamp)::text||'-10-01 00:00:00 GMT'::text)::timestamp + '1 month'::interval) - '1 day'::interval,'D')::int) %7)||' days')::interval 
as last_sunday_october

Posted by pj at 03:52 PM | Comments (0)