Followup to week truncation thread

From: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
To: pgsql-general(at)postgresql(dot)org (pgsql general list)
Subject: Followup to week truncation thread
Date: 2005-09-11 05:55:26
Message-ID: 200509110555.j8B5tR4i017950@gw.tssi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A few days ago there was a thread dealing with how a 'week' breaks.

I just had a need to run a transaction total by week and I wanted
a Sunday-Saturday week, not a Monday-Sunday week which is what the
date_trunc function gives.

Here was my solution:

select (date_trunc('week',mtrantime + interval '1 day')
- interval '1 day')::date as week,
count(*) as tot from trantable group by 1 order by 1;
--
Mike Nolan

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Peter 2005-09-11 07:30:59 Re: back references using regex
Previous Message Michael Fuhr 2005-09-11 04:45:33 Re: Tricky SELECT question involving subqueries