Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26171
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2012-07-28 16:25 -0700 |
| References | <mailman.2525.1343123740.4697.python-list@python.org> |
| Subject | Re: How to represent dates BC |
| From | jwp <james.pye@gmail.com> |
| Message-ID | <mailman.2677.1343517908.4697.python-list@python.org> (permalink) |
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 || ...
$$;
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to represent dates BC Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-24 11:55 +0200 Re: How to represent dates BC jwp <james.pye@gmail.com> - 2012-07-28 16:25 -0700 Re: How to represent dates BC jwp <james.pye@gmail.com> - 2012-07-28 16:25 -0700
csiph-web