C# – Check if date is this date or bigger

c++datetimelinq

I trying to check if a date is this date or bigger inside my linq query with boolean. But it's not working like i want.

This my code

        public bool CheckMonth(int month)
    {
            if (month > System.DateTime.Now.Month)
            {
                return true;
            }
            else if (month == System.DateTime.Now.Month)
            {
                return true;
            }
            else
            {
                return false;
            }
    }

    public virtual IList<DateItem> GetThreeDateToList()
    {
        var data = new ScoutDataDataContext();

        var q = (from d in data.DateDetails
                 where d.Activate == 1 && CheckMonth(d.EndDate.Month) 
                 orderby d.Date.Date.Month descending
                 select new DateItem
                 {
                     Title = d.Title,
                     Date = d.Date.Date + " - " + d.EndDate.Date,
                     Link = d.Link,
                 }).Take(3);

        return q.ToList();
    }

Anyone who nows a diffrent way?

Best Solution

What is it that you want to do? According to your text you want to find out whether a given date is today or later, but the code sample compares only the month (which means that June this year is the same as June last year). If you want to compare the date (including year and day), this comparison will do the job for you:

yourDate.Date >= DateTime.Now.Date