Etrade Griffiths wrote:
> Hi
>
> I am using the Win32com library to pick up data from an EXCEL spreadsheet 
> but am having trouble with dates.  I want to convert a date read from the 
> XL sheet into a float using this snippet
>
> from win32com.client import dispatch
> import time
>
> xlFile="test.xls"
> xlApp=Dispatch("Excel.Application")
> xlApp.Workbooks.Open(xlFile)
> xlSht=xlApp.Worksheets("data")
>
> # OK so far but the problem comes now ...
>
> curr_date=xlSht.Cells(1,3).Value         # returns PyTime
>
> Not how to get the date (as either yy,mm,dd or a single number aka 
> XL).  The ASPN ActivePython site suggests using
>   
It appears that the ActivePython docs may be wrong, as the only method I 
see for a PyTime object is Format. Looking up Format leads to 
curr_date.Format("%y,%m,%d") to get yy,mm,dd.

Or you can, as the ActivePython docs suggest, use int(curr_date) to get 
an integer value which you can then float.

-- 
Bob Gailer
510-978-4454

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to