Date issue in ASP.NET Core MVC: when I use type = month in input code not working

Viewed 42

I am creating a monthly sales report. So in date input, I need only month and year, no need for the day. I used type month in input.

This is my view:

<div class="form-group">
    <label for="Date">Date</label>
    <input type="month" class="form-control" name="Date" id="Date" />
</div>
                        

I need to compare this date with my date in model:

public DateTime Entrydate { get; set; }

In the controller, for comparing the date in input and entry date

private IEnumerable<Sale>GetFilteredData(IEnumerable<Sale>  DateTime? Date)
{
    if (Date != null || Date != default(DateTime))
    {
        result = result.Where(a => a.Entrydate >= Date);
    }
}

It worked when I use type = date in my input, but when I use month, it is not working. What changes do I need to do to solve this problem?

0 Answers
Related