Обсуждение: Timestamp and compatiblity with MySQL

Поиск
Список
Период
Сортировка

Timestamp and compatiblity with MySQL

От
Daniel Mendyke
Дата:
My application (in perl) has to portible

between both MySQL and Postgres.  Most of

the work is rather easy, but I'm having

trouble with TIMESTAMP.

MySQL allows me to use DATE_FORMAT( col_name, '%D %M %Y' )

to format the data.  What function or method does Postgres

provide for formating timestamp data?

Thanks.

-Daniel

--

To reach me remove the 'nospam.'
my address is 'daniel at clacknet dot com'




Re: Timestamp and compatiblity with MySQL

От
Ron Peterson
Дата:
Daniel Mendyke wrote:
>
> MySQL allows me to use DATE_FORMAT( col_name, '%D %M %Y' )
> to format the data.  What function or method does Postgres
> provide for formating timestamp data?

Try to_char( timestamp_col_name, 'DD MM YYYY' ).

See the section on "Formatting Functions" in the distribution's included
html documentation for more details.

________________________
Ron Peterson
rpeterson@yellowbank.com

Re: Timestamp and compatiblity with MySQL

От
Ed Loehr
Дата:
Daniel Mendyke wrote:
>
> What function or method does Postgres provide for formating timestamp data?

http://www.postgresql.org/docs/postgres/x2976.htm

Regards,
Ed Loehr

Re: Timestamp and compatiblity with MySQL

От
Jurgen Defurne
Дата:
Daniel Mendyke wrote:

> My application (in perl) has to portible
>
> between both MySQL and Postgres.  Most of
>
> the work is rather easy, but I'm having
>
> trouble with TIMESTAMP.
>
> MySQL allows me to use DATE_FORMAT( col_name, '%D %M %Y' )
>
> to format the data.  What function or method does Postgres
>
> provide for formating timestamp data?
>
> Thanks.
>
> -Daniel
>
> --
>
> To reach me remove the 'nospam.'
> my address is 'daniel at clacknet dot com'

Since postgreSQL time information is an integer, you don't need to
format timestamp data when inserting. All you need to do is obtain
somewhere your time information. The formatting needs only to
be done on retrieving the data.

Jurgen Defurne
defurnj@glo.be