anil maran wrote: > > 'datetime.datetime' object has no attribute 'split' > > > thisis the error i get
Ah, then your data is not a string, it is a datetime.datetime object. You can format it using datetime.datetime.strftime(): In [1]: import datetime In [2]: d=datetime.datetime.now() In [3]: d Out[3]: datetime.datetime(2006, 7, 3, 6, 24, 2, 93000) In [4]: print d 2006-07-03 06:24:02.093000 In [5]: d.strftime('%Y-%m-%d %H:%M:%S') Out[5]: '2006-07-03 06:24:02' Kent > */Kent Johnson <[EMAIL PROTECTED]>/* wrote: > > anil maran wrote: > > please help me format this string from > > input : 2006-06-16 16:23:27.703000 to > > output: 2006-06-16 16:23:27 > > > > or 2006-06-16 4:23:27 PM > > str.split() can extract everything up to the first period: > In [4]: '2006-06-16 16:23:27.703000'.split('.')[0] > Out[4]: '2006-06-16 16:23:27' > > Kent > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > Yahoo! Messenger with Voice. Make PC-to-Phone Calls > <http://us.rd.yahoo.com/mail_us/taglines/postman1/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com> > > to the US (and 30+ countries) for 2ยข/min or less. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor