> "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