Re: mapping date value (SQL question)

From: "Mancz, James" <James(dot)Mancz(at)Aspect(dot)com>
To: "'Johnson, Shaunn'" <SJohnson6(at)bcbsm(dot)com>, "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: mapping date value (SQL question)
Date: 2002-02-21 14:33:17
Message-ID: 49A6B6B8721CD511BBB000508BD6BE9993BB65@euems2.aspect.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If you want the leading zero, modify it to be like this;

SELECT date_part('y', datefield) || '0' || date_part('qtr', datefield)
FROM tablename;

-----Original Message-----
From: Johnson, Shaunn [mailto:SJohnson6(at)bcbsm(dot)com]
Sent: 21 February 2002 14:32
To: 'Mancz, James'; 'pgsql-general(at)postgresql(dot)org'
Subject: RE: [GENERAL] mapping date value (SQL question)

--that's close. but i need the '0' in the field between the
year and the quarter.

--all of this because a company want's fixed length columns.

--i was reading about something like this:

[example]

select to_char(to_date('05/21/1998'),'Q') from dual

[/example]

--trying to modify it somehow ...

--thanks!

-X

-----Original Message-----
From: Mancz, James

How about:

SELECT date_part('y', datefield) || date_part('qtr', datefield)
FROM tablename;
-----Original Message-----
From: Johnson, Shaunn

Howdy:
I'm running Postgres 7.1.3 on RedHat Linux 7.2, kernel version
2.4.7 rel 10.
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
I was thinking I'd have to use something like a case statement, but
I don't know enough about SQL to do something like that. Somehow, I
had the notion that if it were possible to write 'if-then-else' loops
I could probably do it.
Is there such a mechanism to do what is being asked of me?
Thanks!
-X

Browse pgsql-general by date

  From Date Subject
Next Message Vivek Khera 2002-02-21 14:36:21 Re: [GENERAL] schema error upgrading from 7.1 to 7.2
Previous Message Johnson, Shaunn 2002-02-21 14:31:43 Re: mapping date value (SQL question)