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

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: Bricklen Anderson <banderson(at)presinet(dot)com>
Cc: PostgreSQL SQL List <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:32:08
Message-ID: 48908978.2080700@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>>
>> 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?)
>>
>> Thanks a lot!
>>
>
> http://www.postgresql.org/docs/current/static/functions-formatting.html

This is exactly what I am looking for.

> select to_char(current_date,'Day');
> select to_char(current_date,'D');

1: Sunday
2: Monday
3: Tuesday
4: Wednesday
5: Thursday
6: Friday
7: Saturday

Thank you very much for all your inputs!

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2008-07-30 17:28:28 Re: order function in aggregate
Previous Message Michael Toews 2008-07-30 15:31:57 order function in aggregate