Checking if a date is equal to a date X number of days ago

HI all

I have a date string, and I need to check if it is equal to 10 days ago, or 15 days ago, and if so, to do certain tasks.

I am converting it into a dateTime:
DateTime.ParseExact(dateStr, “dd/MM/yyyy”, CultureInfo.InvariantCulture)
(I found this information on these forums)

I am finding no matter what I do, my process is going out the “else” below. Any thoughts on what I am doing wrong?

It looks like you are comparing DateTime with Date. Have you tested with:

dateConverted.Date = Date.Now.AddDays(-10)

Made the change you suggested, still appears to be going the wrong way?

I edited the assign to Date.ParseExact(dateStr, “dd/MM/yyyy”, CultureInfo.InvariantCulture) and the IF statement to be =

give a try on: =
so the time part will no longer bring in a difference. Have looke here:


Thank worked!!! THANK YOU!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.