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


Groups > comp.lang.python > #11352

Re: How do I convert String into Date object

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.065
X-Spam-Evidence '*H*': 0.87; '*S*': 0.00; 'subject:object': 0.07; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'cheers,': 0.18; 'convert': 0.19; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'pm,': 0.24; 'aug': 0.24; 'string': 0.26; 'sat,': 0.28; 'correct': 0.28; 'import': 0.28; 'message- id:@mail.gmail.com': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.30; "skip:' 10": 0.30; 'chris': 0.32; 'received:209.85.161': 0.35; 'subject:How': 0.35; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; '12:14': 0.84; 'date?': 0.84; 'datetime': 0.84; 'sender:addr:chris': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=zhprtkwUQakcVpnZellrtNDMWeL1kaBLumIeTcOUUwA=; b=ablYDO3HA4eXsHwwgyuwtEM7KEAm+296V2ml3E2Ge8fDoFGD2qC8UrhZnMfFys/f28 tRCfm1JlwrnVQdz5vocGBpd9NKm17yJxZafxGHsOF38ieEfFJ6c2R87K5DiH56EQtJMP LqUunla0WSegERkEvzE2TkMvWHCXAESJ/2hpc=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <83822ecb-3643-42c6-a2bf-0187c07d351d@a10g2000yqn.googlegroups.com>
References <83822ecb-3643-42c6-a2bf-0187c07d351d@a10g2000yqn.googlegroups.com>
Date Sat, 13 Aug 2011 13:09:13 -0700
X-Google-Sender-Auth m0Qihf9LCS8JVcuxAxcZygRosB8
Subject Re: How do I convert String into Date object
From Chris Rebert <clp2@rebertia.com>
To MrPink <tdsimpson@gmail.com>
Content-Type text/plain; charset=UTF-8
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>
Newsgroups comp.lang.python
Message-ID <mailman.2254.1313266161.1164.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1313266161 news.xs4all.nl 23936 [2001:888:2000:d::a6]:50986
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:11352

Show key headers only | View raw


On Sat, Aug 13, 2011 at 12:14 PM, MrPink <tdsimpson@gmail.com> wrote:
> Is this the correct way to convert a String into a Date?
> I only have dates and no time.
>
> import time, datetime
>
> oDate = time.strptime('07/27/2011', '%m/%d/%Y')
> print oDate

from datetime import datetime
the_date = datetime.strptime('07/27/2011', '%m/%d/%Y').date()

Cheers,
Chris

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


Thread

How do I convert String into Date object MrPink <tdsimpson@gmail.com> - 2011-08-13 12:14 -0700
  Re: How do I convert String into Date object MrPink <tdsimpson@gmail.com> - 2011-08-13 12:26 -0700
    Re: How do I convert String into Date object Rafael Durán Castañeda <rafadurancastaneda@gmail.com> - 2011-08-13 22:11 +0200
      Re: How do I convert String into Date object MrPink <tdsimpson@gmail.com> - 2011-08-13 13:25 -0700
    Re: How do I convert String into Date object Peter Otten <__peter__@web.de> - 2011-08-13 22:29 +0200
    Re: How do I convert String into Date object Sibylle Koczian <nulla.epistola@web.de> - 2011-08-13 22:05 +0200
  Re: How do I convert String into Date object Chris Rebert <clp2@rebertia.com> - 2011-08-13 13:09 -0700
  Re: How do I convert String into Date object Roy Smith <roy@panix.com> - 2011-08-13 20:49 -0400
  Re: How do I convert String into Date object MrPink <tdsimpson@gmail.com> - 2011-08-13 22:44 -0700

csiph-web