On Jun 7, 2007, at 15:38 , Fernando Hevia wrote:

Why not? I'm curious if has anything to do with performance or just style?

Not style. Maybe performance because there's fewer function calls, but primarily correctness. By using to_char you no longer have a date— you have a text value—and are relying on the collocation of your database to compare two text values. This can lead to subtle bugs in your code. Similarly, I would never use to_char to compare two integers:

SELECT 20 > 9 AS int_values
    , to_char(20, '9') > to_char(9, '9') AS text_values;

Is this what you would expect? What's the advantage to using to_char?

Michael Glaesemann
grzm seespotcode net



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to