pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRE: DATE Formating Problem Again
2+ messages / 2 participants
[nested] [flat]
* RE: DATE Formating Problem Again
@ 2000-03-02 09:54 Mark Kirkwood <markir@ihug.co.nz>
2000-03-02 11:10 ` Re: [SQL] RE: DATE Formating Problem Again Karel Zak - Zakkr <zakkr@zf.jcu.cz>
0 siblings, 1 reply; 2+ messages in thread
From: Mark Kirkwood @ 2000-03-02 09:54 UTC (permalink / raw)
To: forgacs@negral.com; pgsql-sql; efte@negral.com
>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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] RE: DATE Formating Problem Again
2000-03-02 09:54 RE: DATE Formating Problem Again Mark Kirkwood <markir@ihug.co.nz>
@ 2000-03-02 11:10 ` Karel Zak - Zakkr <zakkr@zf.jcu.cz>
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak - Zakkr @ 2000-03-02 11:10 UTC (permalink / raw)
To: Mark Kirkwood <markir@ihug.co.nz>; +Cc: forgacs@negral.com; pgsql-sql; efte@negral.com
On Thu, 2 Mar 2000, Mark Kirkwood wrote:
> >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
The release 7.0 has to_char/to_date/to_timestamp functions too,
and it is very compatible with Oracle's to_char(). See the PostgreSQL
documentation for more details.
Karel
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-03-02 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-03-02 09:54 RE: DATE Formating Problem Again Mark Kirkwood <markir@ihug.co.nz>
2000-03-02 11:10 ` Karel Zak - Zakkr <zakkr@zf.jcu.cz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox