First change number to correct date format then subtract from todays date


I have a table extract that has dates stored as strings. They come in the format of 17/03/2020. I was able to convert those into dates using:

row(1) = Date.ParseExact(row(1).ToString, “dd/MM/yyyy”, System.Globalization.DateTimeFormatInfo.InvariantInfo)

That would change it from 17/03/2020 to 03/17/2020 00:00:00

However, now I cannot take todays date and subtract it from that date. I’m trying to use it in an if block:

IF - row(1) > 1095


I can’t get it to work. I tried different variations of converting the row(1) to dbl and integer but no luck

use a separate variable for that date

for row(1)?

i can get the portion to work but the row(1) wont

Thats for the IF statement

what is 1095?

its 3 years (365 days * 3)

i’ve tried converting row(1) into both an integer and a double but it says:

Assign: Conversion from string “03/17/2020 00:00:00” to type ‘Double’ is not valid.

varAttribute=DateTime.ParseExact(row(1).ToString, “dd/MM/yyyy”,System.Globalization.DateTimeFormatInfo.InvariantInfo)

if ((DateTime.Now-varAttribute).TotalDays>1095)

what type of variable does varAttribute need to be?


Great that worked! Thank you so much!

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