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!newsfeed3.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'python': 0.09; 'descriptor': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'subject:skip:a 10': 0.09; 'typeerror:': 0.09; 'suggest': 0.11; 'format?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'bit': 0.21; 'import': 0.21; '"",': 0.22; 'testing': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '(most': 0.27; 'header:X-Complaints-To:1': 0.28; 'skip:( 20': 0.28; "skip:' 10": 0.30; 'code': 0.31; 'file': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'traceback': 0.33; 'to:addr:python- list': 0.33; 'skip:d 20': 0.34; 'entered': 0.34; 'something': 0.35; 'received:org': 0.36; 'but': 0.36; 'subject:: ': 0.38; 'mark': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'save': 0.61; 'more': 0.63 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Checking for valid date input and convert appropriately Date: Thu, 21 Feb 2013 23:30:53 +0000 References: <92536c34-cf00-4497-b646-ab79fa4ee062@googlegroups.com> <5bac38bb-df2e-47b8-96dd-2b1c090959e4@googlegroups.com> <125c2ff7-9306-4d8d-955e-aac8b3401d19@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-22-84-96.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: <125c2ff7-9306-4d8d-955e-aac8b3401d19@googlegroups.com> X-Antivirus: avast! (VPS 130221-2, 21/02/2013), Outbound message X-Antivirus-Status: Clean X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361489339 news.xs4all.nl 6845 [2001:888:2000:d::a6]:41396 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39490 On 21/02/2013 23:18, Ferrous Cranus wrote: > Then i try to save the date as MySQL wants but it just aint happening: > > date = datetime.strftime(date, '%Y-%m-%d') > > Can you help me please save the user entered date to MySQL format? > I suggest testing your code at the interactive prompt, so something like. c:\Users\Mark>python Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import datetime >>> date = '21 02 2013' >>> date = datetime.strftime(date, '%Y-%m-%d') Traceback (most recent call last): File "", line 1, in TypeError: descriptor 'strftime' requires a 'datetime.date' object but received a 'str' -- Cheers. Mark Lawrence