Assuming I have a table called MyTable, with a TimeStamp field "Created". I want only extract the Date part of this column, and in my research I found these alternatives:
SELECT created AS "Original", date(created) AS "DateFunction", created::date AS "DoubleColonCast", cast(created as date) AS "CastFunction", date_trunc('day', created) AS "DateTrunc" FROM MyTable
- In matter of SARGability, what is the preferred method?
- What is the "SQL ANSI" (ie more portable) way?
- What is the most common/used in Postgres?