locked
MySQL to dataSet - Date format problem RRS feed

  • Question

  • User-195907812 posted

    I have a problem retrieving dates from a MySQL database between my test and live environments.

    I am retrieving a bunch of records from a MySQL database and moving this data to a dataset.

    Dates are stored on both MySQL servers as "2011-07-13"

    When I move the data in to a dataset, the dates are as follows:

    Test system (correct)...

    <registration_submitted>2011-07-13T00:00:00+01:00</registration_submitted>

    Live system (incorrect)...

        <registration_submitted xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <Year>2011</Year>
          <Month>7</Month>
          <Day>13</Day>
          <Hour>0</Hour>
          <Minute>0</Minute>
          <Second>0</Second>
          <Millisecond>0</Millisecond>
        </registration_submitted>

    Two questions...

    - Does anyone know what is causing the difference?

    - How can I modify my code to store dates in the desired format (as the test system).

    Wednesday, July 13, 2011 7:20 AM

Answers

All replies

  • User-195907812 posted

    Update...

    I just dumped the dataSet to an XML file, this is what I found:

    Test...

    <xs:element name="registration_submitted" type="xs:dateTime" minOccurs="0" />

    Live...

    <xs:element name="registration_submitted" msdata:DataType="MySql.Data.Types.MySqlDateTime, MySql.Data, Version=6.2.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" type="xs:anyType" minOccurs="0" />

    Wednesday, July 13, 2011 9:50 AM
  • User-1694870838 posted

    Hi,

    please check your data format get from database,when move it  into dataset you can convert it format,

    about datetime format you can refer to this link:http://msdn.microsoft.com/en-us/library/aa325278(v=VS.71).aspx 

    Best Regards,

    Damon 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 18, 2011 11:55 PM