Re: How do I convert String into Date object

2011-08-14 Thread Sibylle Koczian
Am 13.08.2011 21:26, schrieb MrPink: I have file of records delimited by spaces. I need to import the date string and convert them into date datatypes. '07/27/2011' 'Event 1 Description' '07/28/2011' 'Event 2 Description' '07/29/2011' 'Event 3 Description' I just discovered that my oDate is not

Re: How do I convert String into Date object

2011-08-13 Thread MrPink
I found this solution. Python: Convert String Date to Date Object http://slaptijack.com/programming/python-convert-string-date-to-date-object/ On Aug 13, 3: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 >

Re: How do I convert String into Date object

2011-08-13 Thread Roy Smith
In article <83822ecb-3643-42c6-a2bf-0187c07d3...@a10g2000yqn.googlegroups.com>, MrPink wrote: > Is this the correct way to convert a String into a Date? > I only have dates and no time. You have already received a number of good replies, but let me throw out one more idea. If you ever need t

Re: How do I convert String into Date object

2011-08-13 Thread MrPink
BTW, here is the Python version I'm using. Will this make a difference with the solutions you guys provided? Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Also, what editor do you guys use? There are so many to chose from. On Aug 13, 4:11 pm, Rafa

Re: How do I convert String into Date object

2011-08-13 Thread Peter Otten
MrPink wrote: > I have file of records delimited by spaces. > I need to import the date string and convert them into date datatypes. > > '07/27/2011' 'Event 1 Description' > '07/28/2011' 'Event 2 Description' > '07/29/2011' 'Event 3 Description' > > I just discovered that my oDate is not an obje

Re: How do I convert String into Date object

2011-08-13 Thread Rafael Durán Castañeda
You can use datetime objects: >>> dt1 = datetime.datetime.strptime('07/27/2011',"%m/%d/%Y") >>> dt2 =datetime.datetime.strptime('07/28/2011',"%m/%d/%Y") >>> dt1 == dt2 False >>> dt1 > dt2 False >>> dt1 < dt2 True >>> dt1 - dt2 datetime.timedelta(-1) On 13/08/11 21:26, MrPink wrote: I have file

Re: How do I convert String into Date object

2011-08-13 Thread Chris Rebert
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

Re: How do I convert String into Date object

2011-08-13 Thread MrPink
I have file of records delimited by spaces. I need to import the date string and convert them into date datatypes. '07/27/2011' 'Event 1 Description' '07/28/2011' 'Event 2 Description' '07/29/2011' 'Event 3 Description' I just discovered that my oDate is not an object, but a structure and not a d

How do I convert String into Date object

2011-08-13 Thread MrPink
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 Thanks, -- http://mail.python.org/mailman/listinfo/python-list