Skip site navigation (1) Skip section navigation (2)

Re: Selecting weekdays from datetime

From: Bill Morrow <wmorrow(at)home(dot)com>
To: Martin Christensen <factotum(at)mail1(dot)stofanet(dot)dk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Selecting weekdays from datetime
Date: 2000-10-10 14:54:10
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Martin Christensen wrote:
> Howdy,
> I have a database of mailing list entries where I would like to do
> some statistics on activity on different days of the week. So say I
> want to do something along the hypothetical lines of
> SELECT COUNT(*) FROM table WHERE day_of_week(date) = 'Mon'
> how do I go about doing that?
> Martin

I believe

select count(*) from table where where to_char(day, 'Day') =
'Monday   '

should do it. Note the three space pad on the end of
'Monday   ' 
to make it the same length as 'Wednesday'

In response to

pgsql-novice by date

Next:From: pejacDate: 2000-10-11 07:03:34
Subject: About index ...
Previous:From: Martin ChristensenDate: 2000-10-10 14:00:14
Subject: Selecting weekdays from datetime

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group