Re: Problem with selecting the first day of the the week - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Problem with selecting the first day of the the week
Date
Msg-id 162867790810291340y320390f3s31d94ffaa54110fb@mail.gmail.com
Whole thread Raw
In response to Problem with selecting the first day of the the week  ("x asasaxax" <xanaruto@gmail.com>)
List pgsql-general
Hello

try

CREATE OR REPLACE FUNCTION public.fdow(date)
 RETURNS date
 LANGUAGE sql
 IMMUTABLE STRICT
AS $function$ select $1 - extract(dow from $1)::int $function$

postgres=# select fdow(current_date);
    fdow
------------
 2008-10-26
(1 row)

regards
Pavel Stehule

2008/10/29 x asasaxax <xanaruto@gmail.com>:
> Hi,
>
>    I need a function to select the first day of the week. For example
> giving  today´s date(29/10/2008).
>
> Can anyone help´s me?
> Thanks!
>

pgsql-general by date:

Previous
From: "x asasaxax"
Date:
Subject: Problem with selecting the first day of the the week
Next
From: "Kevin Galligan"
Date:
Subject: Slow query performance