I have two dates:
DateTime date_of_submission = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"));
DateTime _effective_date = Convert.ToDateTime(TextBox32.Text);
Now the effective date cannot be more than 90 days in the future from date of submission.
How can I do this comparison?
One method that comes to mind is a naive convert date times to strings and then compare dd, mm, yyyy and see if both dates are within 90 days of each other. But I believe there has to be a better solution than that.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
History: The name C is derived from an earlier programming language called BCPL (Basic Combined Programming Language). BCPL had another language based on it called B: the first letter in BCPL.
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
You can subtract two dates, and get a TimeSpan :
TimeSpan difference = _effective_date - date_of_submission;
if(difference.TotalDays > 90)
{
// Bingo!
}
var days = (_effective_date - date_of_submission).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