How can I get the current date but at midnight in a date object instead of a string object?
I know I can do this Date.Now.ToShortDateString, but that returns a string object.
But if I do this Convert.ToDateTime(Date.Now.ToShortDateString), it seems like too much code. Let me know if I should just get over this and use it.
Reason, I need to compare two dates and the date I'm comparing it to only has a date and no time.
There is a DateTime.Today field specifically for that purpose.
You can also use DateTime.Date property to get just the date of any datetime object, so DateTime.Now.Date will also work.
Look at the Date property:
DateTime.Now.Date
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With