compare date

  • Hi,

    I am using the following javascript to find out if the file exists and then get the date of the file.

    Now I would like to return true or false if the date of the file is older than one week.

    How is this done please?

    Thanks

    //**********************************************************************

    // Java ActiveX Script

    //************************************************************************

    function Main()

    {

    var filespec = DTSGlobalVariables("FTPROOT").value + "\\" + DTSGlobalVariables("FILE").Value;

    var f;

    var d

    var fso = new ActiveXObject("Scripting.FileSystemObject");

    if ( fso.FileExists(filespec) == true);

    {

    f = fso.GetFile(filespec);

    d = f.DateLastModified;

    }

    DTSGlobalVariables("FileDateModified").Value = d;

    return(DTSTaskExecResult_Success);

    }

  • is there any difficulty in using Datediff function in the DTS




    My Blog: http://dineshasanka.spaces.live.com/

  • I don't believe there is a datediff in DTS.

    Thanks

  • Even the DateDiff gives the same error (i.e. object required).

    Thanks

    //**********************************************************************

    // Java ActiveX Script

    //************************************************************************

    function Main()

    {

    var filespec = DTSGlobalVariables("FTPROOT").value + "\\" + DTSGlobalVariables("FILE").Value;

    var f;

    var d;

    var fso = new ActiveXObject("Scripting.FileSystemObject");

    if ( fso.FileExists(filespec) == true);

    {

    f = fso.GetFile(filespec);

    d = f.DateLastModified;

    DTSGlobalVariables("FileDateModified").Value = d;

    var dt = new Date();

    var t_date = dt.getDate(); // Returns the day of the month

    var t_mon = dt.getMonth(); // Returns the month as a digit

    var t_year = dt.getFullYear(); // Returns 4 digit year

    //if (DateDiff(dt.getDate(), d.getDate()) < 7)

    if (DateDiff("d", dt, d) <= 7)

    {

    return(DTSTaskExecResult_Success);

    }

    }

    }

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply