What is the best way to findout whether a date falls in particular range?
- by Amit
I tried the following
DateTime start = Convert.ToDateTime(TextBox1.Text);
DateTime end = Convert.ToDateTime(TextBox2.Text);
if (DateTime.Now.Date == start.Date || DateTime.Now.Date == end.Date || (DateTime.Now >= start.Date && DateTime.Now <= end.Date))
{
lblResult.Text = "true";
}
else
{
lblResult.Text = "false";
}
This verifies if the date range is one day also. Any way to reduce the number of conditions above?