How to create datetime object from DbiDate (win32.odbc)?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frank Millman

    #1

    How to create datetime object from DbiDate (win32.odbc)?

    Hi all

    I am using odbc from win32 extensions to connect to MS SQL Server. I
    use mx.DateTime to handle dates. When I select a datetime column from
    the database, odbc returns something called a DbiDate object. I cannot
    find out any information on this type, but mx can convert it to a
    mx.DateTime object using DateTimeFrom(), which is really all that I
    need.

    I am looking into changing from mx.DateTime to using the builtin
    datetime type, but I cannot figure out how to convert a DbiDate object
    to a datetime object.

    First prize would be to have a datetime constructor that takes a
    DbiDate object as input, in the same way that mx does, but this does
    not seem to exist.

    Second prize would be to extract the year/month/day elements from the
    DbiDate object, and construct the datetime object manually. However, if
    I try dir(d), where d is a DbiDate object, I get an empty list, so I
    cannot even see how to extract the elements.

    Does anyone know if this is possible, and if so, how?

    Many thanks

    Frank Millman

  • Larry Bates

    #2
    Re: How to create datetime object from DbiDate (win32.odbc)?

    Frank Millman wrote:[color=blue]
    > Hi all
    >
    > I am using odbc from win32 extensions to connect to MS SQL Server. I
    > use mx.DateTime to handle dates. When I select a datetime column from
    > the database, odbc returns something called a DbiDate object. I cannot
    > find out any information on this type, but mx can convert it to a
    > mx.DateTime object using DateTimeFrom(), which is really all that I
    > need.
    >
    > I am looking into changing from mx.DateTime to using the builtin
    > datetime type, but I cannot figure out how to convert a DbiDate object
    > to a datetime object.
    >
    > First prize would be to have a datetime constructor that takes a
    > DbiDate object as input, in the same way that mx does, but this does
    > not seem to exist.
    >
    > Second prize would be to extract the year/month/day elements from the
    > DbiDate object, and construct the datetime object manually. However, if
    > I try dir(d), where d is a DbiDate object, I get an empty list, so I
    > cannot even see how to extract the elements.
    >
    > Does anyone know if this is possible, and if so, how?
    >
    > Many thanks
    >
    > Frank Millman
    >[/color]
    I've always used

    from mx.DateTime import DateTimeFromCOM Date
    t=DateTimeFromC OMDate(dbidate)

    Larry Bates

    Comment

    Working...