mardi 20 janvier 2015

Comparing creation dates of files in VBScript

This may be very obvious to someone out there but I'm having a lot of trouble trying to solve a bug in VBScript. Within the script, I am running through a bunch of .zip files in a directory and processing ones whose creation date is within a specified range.


For instance, if the user enters two arguments 9/3/2014 and 9/5/2014, I only want to process zip files within that date range.


Here is the if statement I am using:



If Mid(file.NAME,len(file.NAME)-3,4) = ".zip" AND
FormatDateTime(file.DateCreated, 2) >= Wscript.Arguments(1) AND
FormatDateTime(file.DateCreated, 2) <= Wscript.Arguments(2) then


I am using the FormatDateTime function to remove the times from the file creation date. That way I should just be left with a short date (mm/dd/yyyy).


The problem I am having is that I am processing dates outside of the given range. For example if the given range is 9/3/2014 to 9/5/2014 then I also end up processing 9/30/2014 for some reason. Can anyone help solve this?


Aucun commentaire:

Enregistrer un commentaire