tags:

views:

89

answers:

1

I want to sort my list items by date:

I m using

<OrderBy><FieldRef Name='SortDate' Ascending='True'/></Order By>

but its giving me results randomly.Is it possible to sort by date in CAML if not then if there is any other way to retrieve list items sorted on the basis of date....

+1  A: 

Yes you can sort by date using CAML. To test it out try sorting on the Modified field to see if that gets you better results. Is your SortDate field an actual DateTime field, or is it something else like a string?

Paul Lucas
Its a string but I am keeping dates in it...because date can have any format....so is it possible to sort in any way?
AB
Ahh... If your dates are strings they will be sorted alphabetically not chronologically. In order to get sorting correct they must all be formatted like yyyy-MM-dd HH:mm:ss
Paul Lucas
If there is any way to sort If my string is in Format mm/dd/yyyy
AB