Re: Get day name(Mon, Tue... Sun) and day number (1, 2...7) from a date

From: "Milen A(dot) Radev" <milen(at)radev(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Get day name(Mon, Tue... Sun) and day number (1, 2...7) from a date
Date: 2008-07-30 15:22:27
Message-ID: g6q0vn$5nv$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Emi Lu написа:
> Good morning,
>
> Could someone tell me the command to get the weekly day name and day
> number please.
>
>
> I am expecting something like:
>
> sql> select data_part('day name', current_date);
> sql> Monday
>
> sql> select data_part('day number', current_date);
> sql> 1
>
> (Mon =1 ... Sun =7?)

You need "TO_CHAR"
(http://www.postgresql.org/docs/current/static/functions-formatting.html)
- "SELECT to_char(current_date, 'Dy')".

--
Milen A. Radev

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bricklen Anderson 2008-07-30 15:22:29 Re: Get day name(Mon, Tue... Sun) and day number (1, 2...7) from a date
Previous Message Emi Lu 2008-07-30 15:08:52 Get day name(Mon, Tue... Sun) and day number (1, 2...7) from a date