Slava32768
Slava32768

Reputation: 49

JScript date compare

var FSO     = new ActiveXObject("Scripting.FileSystemObject");
var BFolder = "C:\\temp";
var XFolder = FSO.GetFolder(BFolder+"\\");
var FList   = new Enumerator(XFolder.Files);
var today   = new Date();

for (; !FList.atEnd(); FList.moveNext()) {

   var d = FList.item().DateLastModified;
   if (d.getMonth() == today.getMonth) { // <----- *

   }
   else {

   }
}

How do I make the above comparison (*) work?

Upvotes: 0

Views: 702

Answers (2)

Jeff
Jeff

Reputation: 736

You should probably use today.getMonth() in stead of today.getMonth And perhaps replace

var d = FList.item().DateLastModified;

by

var d = new Date(FList.item().DateLastModified);

Upvotes: 2

Marcel Korpel
Marcel Korpel

Reputation: 21763

Assuming d is a Date object you can compare months this way:

if (d.getMonth() == today.getMonth()) { …

(you need to call Date.getMonth).

Upvotes: 0

Related Questions