What is the best way to findout whether a date falls in particular range?

Posted by Amit on Stack Overflow See other posts from Stack Overflow or by Amit
Published on 2010-03-09T08:54:12Z Indexed on 2010/03/09 9:06 UTC
Read the original article Hit count: 232

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about c#2.0

Related posts about datetime