pgsql, mysql and date time functions


Despite years of programming I have never quite got the hang of date time functions. They all look pretty similar and cumbersome to use regardless of programming language or RDBMS.

Date and time functions in mysql are particularly confusing though less confusing than the counterparts in PHP. To simplify things I have been in the habit of calling the unix_timestamp() function to covert evertying to longs, according to what I have seen I am not the only one to use this bad pracitice.

Unfortunatley unix_timestamp() is not supported in Postgres. I did come across a suggestion that seems to work pretty well: select round(date_part('epoch', my_date)) the compatibility problems do not end there. There are several other incompatibilities between the mysql and postgres and I intend to take a closer look at this during the coming weeks.

comments powered by Disqus