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

Re: help with date_part & day of week

From: <me(at)alternize(dot)com>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: help with date_part & day of week
Date: 2005-12-30 01:35:55
Message-ID: 0a9501c60ce1$6229cf80$6402a8c0@iwing (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
> You can really do it using CASE:
> WHEN dow() = 0 THEN 6
> ELSE dow() - 1

how good is this solution in regards to performance? i always thought CASE 
and the such should only be used for last resorts. and now there is also a 
date function involved that gets twice in 6/7 of all cases...

regarding these concerns, can you give me your opinion on this solution i 
came up:

SELECT ((date_part('dow', now()) + 6) % 7) AS weekday


In response to


pgsql-novice by date

Next:From: Christopher BrowneDate: 2005-12-30 02:18:29
Subject: Re: ecommerce soolution
Previous:From: Bruce MomjianDate: 2005-12-30 01:00:00
Subject: Re: help with date_part & day of week

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