Using Conditional "Includes" based on file age

Results 1 to 2 of 2

Thread: Using Conditional "Includes" based on file age

  1. #1
    Join Date
    Dec 1969

    Default Using Conditional "Includes" based on file age

    Hi everyone: I have a web page on which I would like to conditionally "include" a file (a weather observation, in this case) based on the age of the file. I figure I can do this by comparing the system time and the creation date of the file. I have three questions.<BR>-How can I assign system date/time to a variable?<BR>-How can I assign last modified date to a variable?<BR>-Is it possible to compare date/time variables arithmetically? In other words, could I write something like the following:<BR>if sys_time > file_time + 1 then<BR>How do I make it clear that the "1" is an hour, and not a day or a minute?<BR>Thanks, I can be e-mailed at

  2. #2
    Ian Stallings Guest

    Default RE: Using Conditional

    This is a hack of some examples at<BR>but it should work:<BR><BR>&#060;%<BR><BR>filespec = "d:userspath ofilefile_test.asp"<BR> Set fso = CreateObject("Scripting.FileSystemObject")<BR> Set f = fso.GetFile(filespec) <BR> fileModified = f.DateLastModified <BR>Response.write fileModified & "<BR>"<BR>Response.write Now & "<BR>"<BR>Response.write Time & "<BR>"<BR><BR><BR><BR>&#037;&#062;<BR><BR><BR>abov e the system time is set to a variable using the "Now"If fileModified &#060; Now then <BR>response.write "this is old"<BR>End if<BR>statement. Now will return something like "6/6/99 12:11:03 PM"<BR><BR><BR>The last modified property is accessed using the FileSystemObject<BR>using "f.DateLastModified". This will return something like:<BR>"6/6/99 12:05:48 PM"<BR><BR><BR>You can then compare them using:<BR><BR>If fileModified &#060; Now then <BR>response.write "this is old"<BR>End if<BR><BR><BR>But this will always report that the file is old because<BR>unless it was created right now it will be old.<BR><BR>So instead of using Now you may want to use the "Date"<BR>function instead.<BR><BR><BR>I hope this gets you on the right track :)<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts