converting a string data to a float value for access database

M.-A. Lemburg mal at egenix.com
Tue Nov 25 23:05:18 CET 2008


On 2008-11-25 22:37, tedpottel at gmail.com wrote:
> Hi,
> 
> I am trying to copy a sql database to a access database using python.
> I can copy all the fields, but the date.  I can store a float value in
> access data object, ie http://en.wikibooks.org/wiki/JET_Database/Data_types#Dates_and_times
> 
> So access uses a float for a date, and mysql databse uses text, I got
> the following as the output 2008-11-25 09:59:39.
> How can I convert the string 2008-11-25 09:59:39 from mysql to a float
> for access??????

Use mxDateTime:

>>> from mx.DateTime import *
>>> DateTimeFrom('2008-11-25 09:59:39').COMDate()
39777.41642361111

See http://www.egenix.com/products/python/mxBase/mxDateTime/

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 25 2008)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2008-11-12: Released mxODBC.Connect 0.9.3      http://python.egenix.com/

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the Python-list mailing list