Re: How can I sort a datetime column in a dataset.



Hi,

> Im using the following code to sort columns in a data set:
> ds.Tables[0].DefaultView.Sort
>
> However, datetime fields pulled from the database are sorted as strings
> and thus incorrectly. How do I sort the datetime fields properly?
> Thanks.

I did not check it, however it sounds strange to me that the datetime, which
is written in memory as a long that contains ticks which are counted by
hundereds of nanosecond units after the year 01:01:01 would be first
converted to a string. Straight sorting the tick gives the right result.

Did you try this?

(Assuming that your field is really a datetime field and not a real string).

I hope this helps,

Cor




.



Relevant Pages

  • Re: Data conversion with DTS package
    ... Using an Active Script transform you can use ... When you move on to SSIS you will see that it is even less inclined to do implicit conversion. ... combination of string, int, float, datetime fields. ... Float, String to DateTime fields. ...
    (microsoft.public.sqlserver.dts)
  • Converting Sql7 to 2000 version
    ... Can anyone tell where i can find any guide to prevent big error!! ... When using datetime fields, before i used [yyyy-mm-dd] ... Wich problems can i have with the new string limit? ...
    (microsoft.public.sqlserver.server)
  • How can I sort a datetime column in a dataset.
    ... Im using the following code to sort columns in a data set: ... datetime fields pulled from the database are sorted as strings ...
    (microsoft.public.dotnet.framework.adonet)

Loading