Re: Formating Date Data Type?

Lists: pgsql-novice
From: "Ashish Karalkar" <ashish(dot)karalkar(at)info-spectrum(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Formating Date Data Type?
Date: 2007-03-20 05:08:06
Message-ID: 000001c76b6f$5a677520$170211ac@LIONKING.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hello list,

I am storing date as '2007-04-15' in data base as YYYY-MM-DD

Now I want to format this to 15-Apr-2007.

Is there any way

I tries to use extract function but it gives in only digit format also this function does not except column name as input

Is there any way??

Thanks In advance.


From: Phillip Smith <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
To: Ashish Karalkar <ashish(dot)karalkar(at)info-spectrum(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Formating Date Data Type?
Date: 2007-03-21 04:29:17
Message-ID: 1174451357.5345.76.camel@it-laptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Is the column a string data type or a date data type?

Assuming it's a date type, look at the to_char() function in the
documentation.

Cheers,
~p

On Tue, 2007-03-20 at 10:38 +0530, Ashish Karalkar wrote:

> I am storing date as '2007-04-15' in data base as YYYY-MM-DD
>
> Now I want to format this to 15-Apr-2007.


From: Cesar Alvarez <c(dot)alvarezx66(at)gmail(dot)com>
To: Ashish Karalkar <ashish(dot)karalkar(at)info-spectrum(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Formating Date Data Type?
Date: 2007-03-21 06:08:00
Message-ID: 4600CBC0.4090703@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

shouldn't windows make that format, with the regional Settings?
where are you developing your APP.

Ashish Karalkar wrote:
> Hello list,
>
> I am storing date as '2007-04-15' in data base as YYYY-MM-DD
>
> Now I want to format this to 15-Apr-2007.
>
> Is there any way
>
> I tries to use extract function but it gives in only digit format
> also this function does not except column name as input
>
>
> Is there any way??
>
> Thanks In advance.
>

Attachment Content-Type Size
c.alvarezx66.vcf text/x-vcard 120 bytes

From: "Ashish Karalkar" <ashish(dot)karalkar(at)info-spectrum(dot)com>
To: "Cesar Alvarez" <c(dot)alvarezx66(at)gmail(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>, "Phillip Smith" <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
Subject: Re: Formating Date Data Type?
Date: 2007-03-21 07:05:35
Message-ID: 000001c76b97$134d5f60$170211ac@LIONKING.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I am in INDIA

Tried with to_char but it does not take column name/actuall date value as argument for date

With Regards
Ashish
----- Original Message -----
From: Cesar Alvarez
To: Ashish Karalkar
Cc: pgsql-novice(at)postgresql(dot)org
Sent: Wednesday, March 21, 2007 11:38 AM
Subject: Re: [NOVICE] Formating Date Data Type?

shouldn't windows make that format, with the regional Settings?
where are you developing your APP.

Ashish Karalkar wrote:
Hello list,

I am storing date as '2007-04-15' in data base as YYYY-MM-DD

Now I want to format this to 15-Apr-2007.

Is there any way

I tries to use extract function but it gives in only digit format also this function does not except column name as input

Is there any way??

Thanks In advance.


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Ashish Karalkar <ashish(dot)karalkar(at)info-spectrum(dot)com>
Cc: Cesar Alvarez <c(dot)alvarezx66(at)gmail(dot)com>, pgsql-novice(at)postgresql(dot)org, Phillip Smith <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
Subject: Re: Formating Date Data Type?
Date: 2007-03-21 14:40:37
Message-ID: 20070321144037.GA57953@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Wed, Mar 21, 2007 at 12:35:35PM +0530, Ashish Karalkar wrote:
> Tried with to_char but it does not take column name/actuall date
> value as argument for date

Please show exactly what you tried and what the result was. Does
the following help?

test=> create table test (d date);
CREATE TABLE
test=> insert into test values ('2007-04-15');
INSERT 0 1
test=> select to_char(d, 'DD-Mon-YYYY') from test;
to_char
-------------
15-Apr-2007
(1 row)

test=> select to_char('2007-4-15'::date, 'DD-Mon-YYYY');
to_char
-------------
15-Apr-2007
(1 row)

--
Michael Fuhr


From: "Ashish Karalkar" <ashish(dot)karalkar(at)info-spectrum(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: "Cesar Alvarez" <c(dot)alvarezx66(at)gmail(dot)com>, <pgsql-novice(at)postgresql(dot)org>, "Phillip Smith" <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
Subject: Re: Formating Date Data Type?
Date: 2007-03-22 04:41:25
Message-ID: 004601c76c3d$9ce16310$170211ac@LIONKING.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Thanks Michael ,
It works.
With Regards
Ashish....
----- Original Message -----
From: "Michael Fuhr" <mike(at)fuhr(dot)org>
To: "Ashish Karalkar" <ashish(dot)karalkar(at)info-spectrum(dot)com>
Cc: "Cesar Alvarez" <c(dot)alvarezx66(at)gmail(dot)com>; <pgsql-novice(at)postgresql(dot)org>;
"Phillip Smith" <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
Sent: Wednesday, March 21, 2007 8:10 PM
Subject: Re: [NOVICE] Formating Date Data Type?

> On Wed, Mar 21, 2007 at 12:35:35PM +0530, Ashish Karalkar wrote:
>> Tried with to_char but it does not take column name/actuall date
>> value as argument for date
>
> Please show exactly what you tried and what the result was. Does
> the following help?
>
> test=> create table test (d date);
> CREATE TABLE
> test=> insert into test values ('2007-04-15');
> INSERT 0 1
> test=> select to_char(d, 'DD-Mon-YYYY') from test;
> to_char
> -------------
> 15-Apr-2007
> (1 row)
>
> test=> select to_char('2007-4-15'::date, 'DD-Mon-YYYY');
> to_char
> -------------
> 15-Apr-2007
> (1 row)
>
> --
> Michael Fuhr