This is my first project in C#. I need Check if date x are older than some number of days.
Example:
if ( THIS_IS_SAVED_DATE_5_DAYS_AGO < OLDER_THAN_5_DAYS ) {
// Do this if saved date is more than 5 days
}
Thanks for help.
You could use the AddDays
method to construct a new date relative to the current date and then compare the two dates:
DateTime x = ...
if (x < DateTime.Now.AddDays(-5))
{
// x is older than 5 days
}
You can do something like:
if (x < x.AddDays(-1*days)) {
}
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