[python-win32] Re: [Tutor] Date in Excel (Win32Com)

Lloyd Kvam pythontutor@venix.com
Thu, 30 May 2002 17:35:40 -0400


import pywintypes
import mx.DateTime as DateTime

	if type(x) == pywintypes.TimeType:
		x = DateTime.DateTimeFromCOMDate(x)
	x.strftime('%m/%d/%y')

The COM time format is a float.  I don't remember the details.  The
mx.DateTime package offers good support for all date and time issues.

It is not bundled with Python, but is a free download.  (www.egenix.com)


Terje Johan Abrahamsen wrote:

> I use Win32Com to move info from Excel to an AS/400 system. I need to 
> check that the dates corespond in the two systems. In AS/400 I would use 
> this to pick up the value:
> ex = accountcurrents.ex.ActiveSession.Screen.GetString(14, 15, 8)
> then if I type:
> 
>>>> ex
>>>
> I get:
> u'10/30/00'
> 
> However, when I do the same in Excel:
> xl = accountcurrents.xlSheet.Cells(9,2).Value
> And type:
> 
>>>> xl
>>>
> I get:
> <time object at 0x012196C0>
> 
> How can I get a string that I can compare to the ex value, so I can 
> check if the dates are the same?
> 
> Thanks in advance,
> Terje
> 
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice: 
603-443-6155
fax: 
801-459-9582