Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,
I want dates between two dates , Its means list of dates between two dates can u guide or send any snippets
Posted
Comments
justinonday 21-May-12 1:08am    
Make it clear...!

 
Share this answer
 
Comments
JF2015 21-May-12 1:17am    
Good one. +5
sravani.v 21-May-12 1:37am    
Thank you JF2015
P.Salini 21-May-12 1:49am    
Good link +5
sravani.v 21-May-12 1:51am    
Thank you salini
C#
private List<datetime> GetDatesBetween (DateTime startDate , DateTime endDate)
        {
            List<datetime> allDates = new List<datetime>();
            for (DateTime date = startDate; date <= endDate; date = date.AddDays(1))
                allDates.Add(date);
            return allDates;

        }
 
Share this answer
 
v3
you can use loop sequence

e.g.


C#
DateTime dt1 = new DateTime(2012, 5, 1);
        DateTime dt2 = DateTime.Now;

        DropDownList ddl = new DropDownList();
        while (dt1 < dt2)
        {
            ddl.Items.Add(dt1.ToString("dd-MMM-yyyy"));
            dt1.AddDays(1);
        }
 
Share this answer
 
try this url..................
[^]
 
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