I'd like to loop through a data set and change the format of all DateTime columns from the default format returned by SQL Server mm/dd/yyyy hh:mm:ss tt
(e.g. 1/1/2011 3:56:50 PM) to dd-Mon-yyyy
(e.g. 01-Jan-2011). Is this possible?
I can access the datatables for each table in the dataset via the following code block:
Using ds As DataSet = _bo.getHistoryDataSet(projectId)
For Each dt As DataTable In ds.Tables
For Each col As DataColumn In dt.Columns
If col.DataType Is GetType(DateTime) Then
//Format column here?
End If
Next
Next
End Using
But I can't seem to be able to assign a format to the column. Is there a way to assign a general format to the column or do I have to loop through each row inside this loop and assign row(column) = row(column).ToString("Format Here")
?
Thanks!