Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'except:': 0.07; 'try:': 0.07; 'subject:skip:a 10': 0.09; 'to:addr:comp.lang.python': 0.09; 'truncate': 0.09; 'cc:addr:python-list': 0.10; "'%d": 0.16; 'sys.exit(0)': 0.16; 'trying': 0.21; 'of.': 0.22; 'skip:= 20': 0.22; 'cc:2**0': 0.23; 'work.': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'this.': 0.29; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'received:209.85': 0.35; 'anything': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'think': 0.40; 'hours': 0.66; '2013': 0.84 X-Received: by 10.49.75.195 with SMTP id e3mr2226451qew.24.1361491960184; Thu, 21 Feb 2013 16:12:40 -0800 (PST) Newsgroups: comp.lang.python Date: Thu, 21 Feb 2013 16:12:40 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.68.75.81; posting-account=DYJQ-woAAACEPH85Au2BhUVfFTfSfVa4 References: <92536c34-cf00-4497-b646-ab79fa4ee062@googlegroups.com> <5bac38bb-df2e-47b8-96dd-2b1c090959e4@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 94.68.75.81 MIME-Version: 1.0 Subject: Re: Checking for valid date input and convert appropriately From: Ferrous Cranus 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.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361491968 news.xs4all.nl 6960 [2001:888:2000:d::a6]:53497 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39501 Please i have been trying hours for this: try: datetime.strptime(date, '%d m% %Y') date = date.strftime('%Y-%m-%d') except: print( "

date not propetly entered." ) sys.exit(0) =========================== the user enters 21 02 2013 a) i just need to check if its in accepted format b) then truncate the given date to mysql format That's all i want to do and i cant make it work. Plese tell me how to write this. I have tried anything i can think of.