Thread: Timestamp and compatiblity with MySQL
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'
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
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
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