From: | Mark Kirkwood <markir(at)ihug(dot)co(dot)nz> |
---|---|
To: | forgacs(at)negral(dot)com, pgsql-sql(at)postgreSQL(dot)org, efte(at)negral(dot)com |
Subject: | RE: DATE Formating Problem Again |
Date: | 2000-03-02 09:54:54 |
Message-ID: | 38BE3A6E.D18B24C9@ihug.co.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
>I am searching after the date formatting solution, but didn't found a
>correct one.
>
>So example ORACLE has
> - to_char function to make any kind of date format from a date
type:
>to_char(now,'yyyy.mm.dd')
> - to_date to makes a date type from any kind of string: to_date
>('1999.11.23','yyyy.mm.dd')
>(sniped...)
I have wrestled a bit with this myself - being an Oracle dba ( but i'm
alright now....),
the date <-> char conversion is very different is Postgresql.
However I have found that the "date_part" and "interval" functions seem
to do the job ok,
sometimes combined with the casting operator "::datetime".
e.g : ( for release 7.0 )
date -> number
db1=> select date_part('year',now());
date_part
-----------
2000
and char -> interval
db1=> select interval('4 hours'::interval);
?column?
----------
04:00
and char -> datetime via interval
db1=> select ('1999-01-01 '||interval('4 hours'::interval))::datetime;
?column?
------------------------
1999-01-01 04:00:00+13
I hope this helps a bit...
Cheers
Mark
From | Date | Subject | |
---|---|---|---|
Next Message | Karel Zak - Zakkr | 2000-03-02 11:10:39 | Re: [SQL] RE: DATE Formating Problem Again |
Previous Message | Tom Lane | 2000-03-01 18:35:45 | Re: [SQL] Outer Joins (when?) |