Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26171

Re: How to represent dates BC

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <james.pye@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'formatting': 0.07; 'subject:How': 0.09; 'function:': 0.09; 'here?': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'suggest': 0.11; 'language': 0.14; '24,': 0.16; 'subject:dates': 0.16; 'wrote:': 0.17; '>>>': 0.18; "i'd": 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'creating': 0.26; 'select': 0.26; 'replace': 0.27; 'function': 0.30; 'implement': 0.32; 'text,': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'should': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'your': 0.60; 'july': 0.60; 'more': 0.63; 'cast': 0.65; 'nagy': 0.84; 'received:209.85.220.184': 0.91
Newsgroups comp.lang.python
Date Sat, 28 Jul 2012 16:25:05 -0700 (PDT)
In-Reply-To <mailman.2525.1343123740.4697.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=67.180.20.82; posting-account=lYNdCAoAAACR7-wN54pFEFLqzIpaqRgA
References <mailman.2525.1343123740.4697.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 67.180.20.82
MIME-Version 1.0
Subject Re: How to represent dates BC
From jwp <james.pye@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.2677.1343517908.4697.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1343517908 news.xs4all.nl 6988 [2001:888:2000:d::a6]:40672
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26171

Show key headers only | View raw


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 | NextPrevious in thread | Find similar | Unroll thread


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