Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] Q: How to convert int to date?

From: Mattias Kregert <matti(at)algonet(dot)se>
To: patrice(at)idf(dot)net
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Q: How to convert int to date?
Date: 1998-06-24 07:49:37
Message-ID: 3590AF91.17266A08@algonet.se (view raw or flat)
Thread:
Lists: pgsql-general
Patrice Hédé wrote:
>
> Forget my first reply, there is no date(text) function either...

Yes, I know. I thought pg would automagically cast to 'unknown'
when it could not find a valid conversion, and then try again.
Perhaps that could solve many problems.


>
> But you can do that :
> 
> test=> select test, (test+19000000)::text::datetime::date from testint;
>   test|      date
> ------+----------
> 980101|01-01-1998
> 971121|21-11-1997
> 720306|06-03-1972
> (3 rows)
> 
> The test field is a int4 field, so you can do that (not very nice, but it
> works) :)
> 
> Hope this helps !

Yes! It does. This is exactly what I want! Thank you!

/* m */

In response to

pgsql-general by date

Next:From: Aleksey DashevskyDate: 1998-06-24 09:13:21
Subject: Re: [GENERAL] datatype questions
Previous:From: Christian SteindlDate: 1998-06-24 06:56:09
Subject: Re: [GENERAL] ODBC Failure (fwd)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group