Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have attached one dropdownlist for month and one for year based on that i want to calculate no of days in selected month and year with consideration of leap(Feb) year so please give me solution for that ASAP
Posted
Updated 15-Sep-14 22:48pm
v2
Comments
ChintanShukla 16-Sep-14 4:50am    
Homework? What have you tried so far?
George Jonsson 16-Sep-14 4:51am    
And why would anyone want to give you a solution ASAP?
Is anyone in this forum working for you?
Ask nicely or in this case, use your search engine.
Dhananjay32 16-Sep-14 4:55am    
Ok..

 
Share this answer
 
Comments
Dhananjay32 16-Sep-14 4:53am    
But i want to display number of days of selected month and year in textbox with considering leap year how to do that?
Kornfeld Eliyahu Peter 16-Sep-14 4:55am    
YourTextBox.Text = DateTime.DaysInMonth(SelectedYear, SelectedMonth);
Format your dropdowns so that the year is selected first.

Based on the year selected you can determine if the year is a leap year or not if(year%4 == 0) then it's a leap year!
 
Share this answer
 
Comments
George Jonsson 16-Sep-14 4:59am    
This is not entirely correct
1. Divide the year for which you are trying to determine a leap year by four. If the year is not divisible by four, it is not a leap year. If the year is divisible by four, continue to step two.
2. Divide the year by 100. If the year is not divisible by 100, it is a leap year. If the year is divisible by 100, proceed to step three.
3. Divide the year by 400. If the year is not divisible by 400, it is not a leap year. If it is divisible by 400, it is a leap year.
qadirv 16-Sep-14 9:37am    
@GeorgeJonsson Thanks for the update. Yes, the rules for a leap year are more detailed than I had thought. I had to look it up! He's better off sticking to the DateTime class to get the details!
Dhananjay32 22-Sep-14 5:30am    
Thank you for replay

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