Substract Current date-7 days from the modified date of the directory

Hi People,

I got modified date of the directories in for each item indirectrories.getdir(“Path”)

Datemodified(datetime variable)= Directory.GetLastWriteTime(item)

But now modified date should be current date-7 days in if condition, then perform actions

How to do that, pls help

Hey @sonesh.bansal,

You can split the filename by whatever seperates the name from the date, convert the date substring to DateTime, then compare it to today’s date minus 7 days, it would look something like this in an if statement:

CDate(FilenameArray(1)) <= DateTime.Now.AddDays(-7)

1 Like

Excellent Buddy. I achieved it like this

image

1 Like

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