I know this is probably a pretty simple question, but i am trying to write a function that returns a bool value of “true” if a date passed is in the future, like this:
bool IsFutureDate(System.DateTime refDate)
{
if (refDate > DateTime.Now) // This doesn't seem to work
return true;
return false;
}
Anyone tell me who to write a function like this that actually works?
Thanks
The only thing I can think of is you might get undefined behaviour if refDate == today.
DateTime.Now includes the time. If refDate if for say today at 3:00 and you run it at 2:00 it will return true. If you run at 4:00 it will return false.
Compare it to DateTime.Today and that will just return the date, preventing the time of day influencing it.
Other than that it should all be fine..