Search Postgresql Archives

Followup to week truncation thread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux