[Tutor] Shifts and DateTime problems

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Wed, 6 Feb 2002 15:51:49 -0800 (PST)


On Wed, 6 Feb 2002 mikalzet@libero.it wrote:
> cursor.execute('select time("Begin") from shift where
> "Type" = \'Automedica\' ;')              # backslashes needed to protect '
> cursor.fetchone()
> ['20:00:00']
> 
> I get what I want ... but this is a string I believe, not a DateTime
> variable or even an int.

Ah!  Be careful: it's a LIST that contains a single string.  
cursor.fetchone() always returns a list of columns, even if there's just
one column

> b = DateTimeFrom(cursor.fetchone())

Try:

    b = DateTimeFrom(cursor.fetchone()[0])

instead; that should work better, although I haven't had enough time with
mx.DateTime to be sure about this.