How to check if a DateTime occurs today?

.net, c#, datetime

Solution

if (newsStory.WhenAdded.Date == DateTime.Today)
{

}
else
{

}

Should do the trick.

Problem

Is there a better .net way to check if a DateTime has occured 'today' then the code below? ``` if ( newsStory.WhenAdded.Day == DateTime.Now.Day && newsStory.WhenAdded.Month == DateTime.Now.Month && newsStory.WhenAdded.Year == DateTime.Now.Year ) { // Story happened today } else { // Story didn't happen today } ```

Original source