Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I was wondering if i have 3 random dates.

11/12/2012 9/24/2011 12/29/2008,

I'd like to have

September 9/24/2011

November 11/12/2012

December 12/29/2008

instead of using the query to sort by years, i want it to sort by months, how would i achieve this?

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

I think you do not have any OOB keywords for this. Below is what you can try:

  1. Get the datatable from the list
  2. Add a new column called "MONTH" to datatable
  3. Populate this column's value for each row in datatable with something like below
    FOREACH (Datarow DR in DT.Rows)
    {
    DR["MONTH"] = DateTime.Parse(DR["DATECOLUNM"].ToString()).ToString("MM");
    }
  4. Then create a dataview with sort based on column "MONTH"
  5. Finally use the dataview for binding it to your control
share|improve this answer
add comment

Will,

When you try to sort the dates i believe what you are expecting can't be achieved. When sorting is applied it would do it based on the years months and dates only. Any specific reason why you need this kind of sorting ?

share|improve this answer
1  
Check the other answer out dude, it will show you how this sort of thing is done. –  Hugh Wood Nov 20 '12 at 9:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.