Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have to store date from 11/2/2013 to 15/2/2013 in array in asp.net c#.how to store it as

arr[0]=11/2/2013
arr[1]=12/2/2013
arr[2]=13/2/2013
arr[3]=14/2/2013
arr[4]=15/2/2013
Posted
Comments
Sergey Alexandrovich Kryukov 11-Feb-13 2:06am    
Store where? In array? What's the problem?
—SA
Member 9511889 11-Feb-13 2:07am    
i hav to store it in array

1 solution

HI,

try this,
C#
DateTime stDate = Convert.ToDateTime("11/2/2013");
DateTime edDate = Convert.ToDateTime("15/2/2013");
int count = edDate.Subtract(stDate).Days;
DateTime[] dates = new DateTime[count];
for (int i = 0; i < count; i++)
{
    dates[i] = stDate.AddDays(i);
}


hope this helps.
 
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