Click here to Skip to main content
15,915,501 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Iam developing app in that i want to display month wise date of births in grid view.can any one know how to display it please give me suggestions
Posted
Updated 1-Jun-14 18:26pm
v3
Comments
Prasad Avunoori 2-Jun-14 0:31am    
Can you please share your sample output and your database table structure?
Bh@gyesh 2-Jun-14 1:03am    
It is good if you share your code here. but you can try following in your SP or query which is used to bong datagrid :
SELECT * FROM myTable ORDER BY Year(myDateColumn), Month(myDateColumn)

You need to do sorting on year also. so have written this type of query

1 solution

Try this sample.
this might help you..


C#
List<DateTime> lstAllDates = new List<DateTime>();
           lstAllDates.Add( new DateTime (2014,12,25)); // december
           lstAllDates.Add(new DateTime(2014, 10, 25)); // october
           lstAllDates.Add(new DateTime(2014, 11, 25)); //november
           lstAllDates.Add(new DateTime(2014, 4, 25)); // april
           lstAllDates.Add(new DateTime(2014, 5, 25)); // may
           lstAllDates.Add(new DateTime(2014, 5, 26)); // may
           lstAllDates.Add(new DateTime(2014, 5, 24)); // may
           lstAllDates.Add(new DateTime(2014, 7, 25)); // july

          List<DateTime> lstMonthWise =  lstAllDates.OrderBy(k => k.Month).ThenBy(k=>k.Day).Select(k => k).ToList();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900