When I googled “sorting dates in a datagrid in flex” I found all sorts of outdated material, and some really complicated results, that i tried, but they just didnt happen to work in my situation… i’m not sure what everyone else was doing to create their dates, but I’ve heard a number of people saying it was very hard, or at least harder than they imagined…


that it is… a true statement in deed… just a note, but i havent even tried filtering on this… so forgive me if my solution wont work for it…

I kept battling this issue, and went back to one of the books i read “Adobe Flex 2 training from the source” and found an example in there, and built from it…

/////////////////////script block/////////// private function dateLabel(item:Object, column:DataGridColumn):String
return dateFormatter.format(item[column.dataField]);

/////////////////////script block///////////
<mx:DateFormatter id=“dateFormatter”/>

<mx:DataGrid dataProvider=“{acData}”>
<mx:DataGridColumn dataField=“name” />

<mx:DataGridColumn dataField=“dob”


Please refer to the source links at the top and bottom of the entry for the real source… that code block is not safe to copy and paste and just work…. its just psuedocode.

If you notice I use a mx:DateFormatter id=”dateFormatter” and by default the format is ‘mm/dd/yyyy’ so we dont need to supply a format for this example…

and in the script block there is a very simple function that just formats the label of the date column… and returns a string… and my sorting is working fine for now… please feel free to comment if you see any downfalls in what I have done…