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


Groups > comp.lang.python > #65658

Fwd: datetime formatting output

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ikorot01@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; ';-)': 0.03; 'output': 0.05; 'none:': 0.07; 'debugger': 0.09; 'formatting': 0.09; 'objects,': 0.09; 'stored': 0.12; '23,': 0.16; 'chris,': 0.16; 'igor': 0.16; 'sat,': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'module': 0.19; 'help.': 0.21; 'feb': 0.22; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'putting': 0.22; '\xa0if': 0.24; 'question': 0.24; '&gt;': 0.26; 'possibly': 0.26; '----------': 0.26; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'field,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'getting': 0.31; 'url:python': 0.33; 'date:': 0.34; 'maybe': 0.34; 'problem': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'shows': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'previous': 0.38; 'forwarded': 0.39; 'subject:': 0.39; '12,': 0.39; 'generating': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'field.': 0.61; 'subject:Fwd': 0.61; "you're": 0.61; 'show': 0.63; 're:': 0.63; 'real': 0.63; 'field': 0.63; 'as:': 0.81; 'milliseconds': 0.84; 'p.s.:': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ZOiwv+HUjeypiYcNeTCvDWztxHsR/lhWDSEA0aOxAV0=; b=U9NM+ldEuDz0NrOIvZTNy512EZn3AEiWnKyFuHWUGl3AaPcf7u7mVdDq/e/o+VIjcp vgI+S+FcAwEib8votdVBBPxOl4ViDwNjvbGaXsJ3vYHuCsb0krngLi08abp8Q2Qdx5Fr 8jo1OtcP/vyYlwIj9pRyjYCOlOYBfOfonKAoGYnNO7TU4dP/cCnxK8+bhJNvI3xWHz63 RowTSMdpbBHxBkGI303jELTh9KP60+myecftUDYHRLtLe5GaabeI0F3gIb1onXAh3QNh nNMKmmu0tswLrQaStaukoyuLAFPLUZL60esDkFerE93fhUELfJIK1ZCdtEhaP54gAnJv fLwQ==
MIME-Version 1.0
X-Received by 10.52.247.231 with SMTP id yh7mr13755vdc.34.1391850391001; Sat, 08 Feb 2014 01:06:31 -0800 (PST)
In-Reply-To <CA+FnnTx0hd2zfQHy0tdO+1NzJy74PPKZWrPN8dz-Dknz2GG17Q@mail.gmail.com>
References <CA+FnnTzV5kSJm=n0MiX6AVfnHnF4v3qq4sDT3cGnMJOxta3BZw@mail.gmail.com> <CAPTjJmqtwttJ8k2XOqoFe0QybkBQwVtw_P944y-1Cm2etqn=_A@mail.gmail.com> <CA+FnnTx0hd2zfQHy0tdO+1NzJy74PPKZWrPN8dz-Dknz2GG17Q@mail.gmail.com>
Date Sat, 8 Feb 2014 01:06:30 -0800
Subject Fwd: datetime formatting output
From Igor Korot <ikorot01@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=001a1133c9aa22df7b04f1e16c65
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6532.1391850399.18130.python-list@python.org> (permalink)
Lines 131
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391850399 news.xs4all.nl 2978 [2001:888:2000:d::a6]:35616
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65658

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

---------- Forwarded message ----------
From: Igor Korot <ikorot01@gmail.com>
Date: Sat, Feb 8, 2014 at 1:06 AM
Subject: Re: datetime formatting output
To: Chris Angelico <rosuav@gmail.com>


Chris,


On Sat, Feb 8, 2014 at 12:45 AM, Chris Angelico <rosuav@gmail.com> wrote:

> On Sat, Feb 8, 2014 at 7:40 PM, Igor Korot <ikorot01@gmail.com> wrote:
> > I am reading data from the DB (mySQL) where the datetime field is stored
> as:
> >
> > 2012-12-12 23:59:59.099
> >
> > When I retrieve this date I am successfully see under debugger the
> dateteime
> > object with (2012, 12, 12, 23, 59, 59, 099)
> >
> > However as you can see from my previous post this date shows up
> incorrectly
> > as:
> >
> > 2012-12-12 23:59:59.000099
> >
> > Notice 3 extra 0's in the milliseconds field.
>
> It's not a milliseconds field, that's why :) The real question is: Why
> is the datetime you're getting from MySQL putting milliseconds into
> the microseconds field? Possibly if you show your code for generating
> those datetime objects, that would help.
>

Nothing fancy, really. ;-)

import MySQLdb as mdb
self.conn = mdb.connect()
self.cur = self.conn.cursor()
self.cur.execute("SELECT * FROM mytable")
db_results = self.cur.fetchall()
for row in db_results:
     my_dict = {}
     #Fill in my_dict
     if row[3] is not None:
          my_dict["Install"] = row[3]

That's all.

P.S.: Maybe its a problem with the datetime module which formats the
datetime incorrectly?


> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Fwd: datetime formatting output Igor Korot <ikorot01@gmail.com> - 2014-02-08 01:06 -0800

csiph-web