As the title states, what methods / activities might be helpful to compare a date grabbed from a get text method, in the form of this: 8/20/2018 6:28:59 PM
This is being stored in a variable, dateGrabbed, as a generic value. How would I then take this value and compare it to a date that is 48 hours less than itself? For example
If dateThatIsTwoDaysLess < dateGrabbed… Do something.
Noting that dateThatIsTwoDaysLess is always changing depending on the date grabbed.
Any insight on a helpful activity or method would be awesome! I am good with the logic and can probably get my way around if anyone can offer some guidance. I thank you in advance!
You can also do DateTime.Now.AddDays(-2) instead of now.Subtract(48:00:00). It might be a little more readable in some cases. @nlee1131’s answer does the same thing by subtracting 48 hours.
Huge help, thank you! I want to remark when I first did this the dates were comparing wrong. The if statement was saying that a 2018 date was greater than a 2019 date. Well for any future adventurer reading this, remember to make sure both variables are of type System.DateTime lol. Thanks again!