[python-win32] fiddling with results from an ADODB access.

Mark Ainsworth MarkA@sundance.com
Thu, 29 Aug 2002 12:01:34 +0100


Sorry if this is a dumb question, but I can't seem to find the answer
anywhere. I have a simple asp page displaying the contents of a remote
dbase. It works ok but...

The values returned for the date field are formatted using US layout ie.d
mm/dd/yy I want to change them to UK values dd/mm/yy. However all the
conversion routines I have tried don't want to work. The values returned
aren't date/time, even thought that is the allocation in the dbase. They
aren't simple strings either. Yet I can write them to the HTML page without
problems. The timespent value is stored as an integer, but again it won't
behave as an integer. If I try converting it using int() it comes back with
an error message saying it isn't a string, but it is a Unicode. But the
Unicode decoding routines won't work either.

So the simple question is:

How can I perform simple conversion on returned values so I can actually do
things with them? I need to convert to date/time and integer values.

Thank you for your patience.

TotalTime = 0
while not objRS.EOF:
  Response.Write('<tr><td width="15%">')
  Response.Write(objRS("Project"))
  Response.Write('</td><td width="15%">')
  Response.Write(objRS("LogDate"))
  Response.Write('</td><td width="10%">')
  stTime = "%s" % objRS("TimeSpent").Value  # doesn't matter if I use .value
or not.
						# stTime still doesn't
behave like a string so
                                                         # I can convert it
latter.
  Bert = int(stTime)
  Response.Write(stTime)
  Response.Write("</td></tr>")
  objRS.Move(1)
objRS.Close()

Error Type:
Python ActiveX Scripting Engine (0x80020009)
Traceback (most recent call last): File "<Script Block >", line 30, in ?
bert = int(stTime) ValueError: invalid literal for int(): 3.2 
/asptest/timesheet/ProjectHistory.asp, line 51
bert = int(stTime)
Rgds.

Mark Ainsworth
Quality Manager
Sundance Multiprocessor Technology Ltd.
Chiltern House, Waterside, Chesham, Bucks HP5 1PS
Tel. +44 1494 793167 Fax. +44 1494 793168
MarkA@sundance.com http://www.sundance.com