From: | Thomas Lockhart <lockhart(at)fourpalms(dot)org> |
---|---|
To: | "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com> |
Cc: | postgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: mapping date value (SQL question) |
Date: | 2002-02-21 15:18:41 |
Message-ID: | 3C750FD1.4D5DB582@fourpalms.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> "Johnson, Shaunn" wrote:
> I've created a table which includes the date. I have been instructed
> to map the date into something that reflects the quarter of the year
> on the fly (somewhere in the script). For example:
> (currently) date: (needed) quarter:
> 2001-02-26 200101
> 1998-05-12 199802
> 803-11-11 80304
> Is there such a mechanism to do what is being asked of me?
select date_part('quarter', date 'now');
gets you the current quarter, and
select date_part('year', date 'now') || date_part('quarter', date
'now');
gets you both year and quarter.
However, you may want to use the to_char() functionality to get more
control over the formatting:
select to_char(date 'now', 'YYYY0Q');
Good luck!
- Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | paul simdars | 2002-02-21 16:33:41 | ANY GOOD USER'S GUIDE ONLINE?? (with simple examples) |
Previous Message | Liam DeMasi | 2002-02-21 15:13:18 | Re: libpq++ problem |