Bug #7032 MySqlDateTime in Datatables sorting by Text, not Date.
Submitted: 6 Dec 2004 10:20 Modified: 9 Dec 2004 18:49
Reporter: Barry Zubel Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.2 OS:Windows (WinXP)
Assigned to: Reggie Burnett CPU Architecture:Any

[6 Dec 2004 10:20] Barry Zubel
Description:
Dates displayed in a datatable sort by a string comparison when the column header is clicked to perform a sort.

How to repeat:
Okay, an odd one that I've probably managed to screw up myself (tee hee).

The following extracted code should reproduce the problem: (parts removed for brevity)

sSql = "SELECT DATECOLUMN, SOMEOTHERFIELD FROM YOURTABLE ORDER BY SOMEOTHERFIELD ASC" (where DATECOLUMN is a DATE or DATETIME Mysql Type, SOMEOTHERFIELD can be
anything)

...
(instantiate connector, command, and dataadapter and fill datatable with
results)
...

myDataGrid.DataSource = myDataTable

Now the important thing is to have source data that spans several months. When the datagrid is displayed, simply click on the DATECOLUMN column header to resort by date ascending or descending.

I have found that the DataTable actually seems to text-sort, instead of date-sort.

For example, The dates:

01/10/2004
01/11/2004
02/10/2004
02/11/2004

Will appear IN THAT ORDER, instead of the more logical (and expected):

01/10/2004
02/10/2004
01/11/2004
02/11/2004

(Based on the UK date format, which is DD/MM/YYYY)
[9 Dec 2004 18:49] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html