Check if file using current 6 week period exists or else create new file with fresh date?

Hi. I am looking to check if a file using the current 6 week period from the date it was created exists. If it does not exist a new 6 week file with the date format dd/mm/yyyy in the title will be created. It will be a rolling six week file where a new version will be created every 6 weeks. What would be the best approach to check if it is using the current 6 week period from the date it was created? Any advice would be greatly appreciated, thanks.

Hi @ciaramkm do the file created would have the date associated with name ?

Hi, yes the file would have the date format dd/mm/yyyy created into the title when created

@ciaramkm

Can you provide sample file and also a example screenshot

I believe this will help for clear understanding of your usecase

Follow Link

Thanks

Hi @ciaramkm,

You could use an if statment which compares the date in the filename with the date of 6 weeks ago, it would look something like this:

CDate(filename.split(" "c)(1)) < DateTime.Now.AddDays(42)

You would need to split your filename so it only contains the date. You would also add 42 days to the second date as this is 6 weeks.

It keeps converting the file date retrieved from the title 10/02/2019 to the format of MM/dd/yyyy as shown in message box when using the CDate command and also it’s not recognising the correct 6 week period in the if statement as keeps going into then statement when it should be older than 6 weeks. Any suggestions on how to correct this?

Hey @ciaramkm,

You can specify the format of the DateTime after adding the days, like so:
image

I am having an issue converting today’s date from string dd/MM/yyyy to Date so I will continue looking at that:
image
image