Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting an xml element as date/time instead of string

Status
Not open for further replies.

bopritchard

Programmer
Jan 27, 2003
199
US
can i sort an xml element as a date/time type instead of as a string WITHOUT THE USE OF A SCHEMA FILE?

i'm working in vb.net

here's a snippet of my code:

Dim objDataView As New DataView(objDataSet.Tables("error"))
Dim objDataTable As New DataTable
objDataTable = objDataView.Table

'Custom names for the columns
objDataTable.Columns(0).ColumnName = "Error Date"
objDataTable.Columns(1).ColumnName = "Message"
objDataTable.Columns(2).ColumnName = "Page"
objDataTable.Columns(3).ColumnName = "User"

'Sorting criteria
objDataView.Sort = "Error Date DESC"

dgrValues.DataSource = objDataView
dgrValues.DataBind()
 
If you format your date as ISO-8601 (as the W3C XML spec says you should) it will naturally sort: yyy-mm-ddThh:mm:ss

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top