How to represent dates BC
jwp
james.pye at gmail.com
Sat Jul 28 19:25:05 EDT 2012
On Tuesday, July 24, 2012 2:55:29 AM UTC-7, Laszlo Nagy wrote:
> >>> conn.getqueryvalue("select '1311-03-14 BC'::date")
> What is the good representation here? Should I implement my own date
Do your datetime formatting in postgres: "select '1311-03-14 BC'::date::text"
PG does have a have a reasonable set of functions for working with datetime.
If you need something more complicated than a simple cast to text, I'd suggest creating a function:
CREATE OR REPLACE FUNCTION fmt_my_dates(date) RETURNS text LANGUAGE SQL AS
$$
SELECT EXTRACT(.. FROM $1)::text || ...
$$;
More information about the Python-list
mailing list