how can i find number of days in a given year and month
-
is 2100 really not a leap year? EDIT: It's OK I WIKI it and got an answer ;)
Life goes very fast. Tomorrow, today is already yesterday.
i dont think
-
how can i find number of days in a given year and month
-
i don't know if the user will enter 2009 or 2008 or any month i want to take the data from the user
modified on Tuesday, June 2, 2009 4:19 AM
-
Many Thanks and i'm very happy from Your cooperation
-
Ok this is what you should use instead...
if(year % 4 == 0 && year % 100 == 0 ? year % 400 == 0 : true)//hope you get that logic
//is leap year
else
//not leap yearLife goes very fast. Tomorrow, today is already yesterday.
you realy have come to the right solution thank you
-
i don't know if the user will enter 2009 or 2008 or any month i want to take the data from the user
modified on Tuesday, June 2, 2009 4:19 AM
-
Ok this is what you should use instead...
if(year % 4 == 0 && year % 100 == 0 ? year % 400 == 0 : true)//hope you get that logic
//is leap year
else
//not leap yearLife goes very fast. Tomorrow, today is already yesterday.
-
Or if you don't want to reinvent the wheel:
if (DateTime.IsLeapYear(year)) {
// is leap year
} else {
// not leap year
};)
Despite everything, the person most likely to be fooling you next is yourself.
-
how can i find number of days in a given year and month
i finished simple code for this topic and i want you to review it sory for not optimized code but see the idea download the project: http://www.geocities.com/ahmed_117/Month.zip[^]
-
i finished simple code for this topic and i want you to review it sory for not optimized code but see the idea download the project: http://www.geocities.com/ahmed_117/Month.zip[^]
Have a look at this:
private void button1_Click(object sender, EventArgs e) {
button1.Enabled = false;
int year = dateTimePicker1.Value.Year;
int month = dateTimePicker1.Value.Month;
DateTime start = new DateTime(year, month, 1);
dateTimePicker1.Value = start;
int days = DateTime.DaysInMonth(year, month);
for (int i = 0; i < days; i++) {
dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells[0].Value = start.AddDays(i).DayOfWeek;
dataGridView1.Rows[i].Cells[1].Value = start.AddDays(i).ToShortDateString();
}
}Despite everything, the person most likely to be fooling you next is yourself.
-
Have a look at this:
private void button1_Click(object sender, EventArgs e) {
button1.Enabled = false;
int year = dateTimePicker1.Value.Year;
int month = dateTimePicker1.Value.Month;
DateTime start = new DateTime(year, month, 1);
dateTimePicker1.Value = start;
int days = DateTime.DaysInMonth(year, month);
for (int i = 0; i < days; i++) {
dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells[0].Value = start.AddDays(i).DayOfWeek;
dataGridView1.Rows[i].Cells[1].Value = start.AddDays(i).ToShortDateString();
}
}Despite everything, the person most likely to be fooling you next is yourself.
a very Clever man this what i want to reach thank you