I needed to delete some files from a folder on the E:\ drive via SQL. The file name looks like this like this:
20080712_200807131600_KickYourAss.dat
The 1st section shows yyyymmdd, based on that, I parsed out whatever is necessary and nuke anything that’s older than 15 days. In the script, I’ve used (select getdate() – 15), you can also use select dateadd(day, -15, getdate()).