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: 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 To: MrPink 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Sat, Aug 13, 2011 at 12:14 PM, MrPink 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