Ask a Question related to ASP, Design and Development.
-
CJM #1
DateDiff problem on different servers
I have an ASP page that lists files and folders in a directory. I'm using a
cookie to record the last time this page was visited, and I intend to show
links that are created/modified from that date minus 30mins to the
present... eg effectively new and modified files:
If DateDiff("n", subfolder.DateLastModified, sLastVisit ) < 30 Then.... etc
On my test machine this mechanism works OK, but on the live server (Win2k,
IIS5) I get some funny behaviour.
I create a new folder, and run the page. The value this expression returns
on XP is 0 and on Win2K is 43200. Refreshing every minute...on XP the value
increases, 1,2,3 etc... On Win2k, it decreases, 43200,43199,43198 etc....
Folders created days ago have values like 37415
The file list is similar:
If DateDiff("n", file.DateLastModified, sLastVisit ) < 30 Then etc....
On the Win2k m/c, a new file returns 43200 again...
Am I missing something?? Do the DateDiff functions behave differently on
different servers (ie different versions of IIS)?
Help!
Thanks
Chris
Bigger Code Snippet (some key settings are stored in an include file):
<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 0
Dim folderspec, fso, fold, subfolder, files, file, subfld
Dim sFilter, sStartFolder, sStartPath, sTitle, sContact
Dim aDirs, i, j , sLink
Dim sLastVisit, sCookie, sDateClass, sMaxDiff
'Read LastVisit cookie
sLastVisit = Request.Cookies.Item("QADocs")("LastVisit")
If sLastVisit = "" Then
'sLastVisit = FormatDateTime(Now(),VBShortDate)
sLastVisit = Now()
End If
Response.Write sLastVisit
'Set/Update Cookie
'Response.Cookies("sCookie")("LastVisit") = FormatDateTime(Now(),
VBShortDate)
Response.Cookies.Item("QADocs")("LastVisit") = Now()
%>
<!-- #include file="config.asp" -->
<%
'Recover subfolder name if available
subfld = Request.Querystring("sub")
subfld = subfld & "/"
'create full folder path
folderspec = Replace(sStartPath & subfld, "/", "\")
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><%=sTitle%></title>
<link type='text/css' rel='stylesheet' href='Quality.css'>
</head>
<body>
<div id='header'>
<h2><%=sTitle%></h2>
</div>
<div id='outer'>
<p>Note: Files or folders that have been added or modified since your last
visit have their dates shown <span class="new">like this.</span></p>
<table id='tbls'>
<tr id="breadcrumbs">
<td colspan="2">
<%
Response.Write "<a href='./quality.asp'>" & sStartFolder & "</a>"
aDirs = Split(subfld,"/")
For i = 1 to UBound(aDirs)
Response.Write " > <a href='"
sLink = ""
For j = 1 to i
sLink=sLink & "/" & aDirs(j)
Next
Response.Write "./quality.asp?sub=" & sLink
Response.Write "'>" & aDirs(i) & "</a>"
Next
%>
</td>
</tr>
<tr>
<td>
<!-- Folders table -->
<table class="fld">
<colgroup class="lhs" />
<colgroup class="rhs" />
<tr>
<td class="title">Folder Name</td>
<td class="title">Last Modified</td>
</tr>
<%
'Create FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
'Loop through Folders
Set fold = fso.GetFolder(folderspec)
for each subfolder in fold.subFolders
'ignore system or hidden folders - signified by "_"
If Left(subfolder.name,1) <> "_" Then
If DateDiff("n", subfolder.DateLastModified, sLastVisit ) < sMaxDiff Then
sDateClass = "new"
Else
sDateClass = ""
End if
%>
<tr>
<td><a class="folder"
href='quality.asp?sub=<%=subfld &
subfolder.name%>'><%=subfolder.name%>...</a></td>
<td
class="<%=sDateClass%>"><%=FormatDateTime(subfolde r.DateLastModified,
VBShortDate)%><%= "..." & DateDiff("n", subfolder.DateLastModified,
sLastVisit)%></td>
</tr>
<%
End if
next
%>
</table>
</td>
<td>
<!-- Files table -->
<table class="fil">
<colgroup class="lhs" />
<colgroup class="rhs" />
<tr>
<td class="title">File Name</td>
<td class="title">Last Modified</td>
</tr>
<%
'Loop through Files
set files = fold.files
for each file in files
If Instr(1, sFilter, lcase(right(file.name,3))) Then
If DateDiff("n", file.DateLastModified, sLastVisit ) < sMaxDiff Then
sDateClass = "new"
Else
sDateClass = ""
End if
%>
<tr>
<td><a class="file" href='.<%=subfld &
file.name%>'><%=file.name%></a></td>
<td
class="<%=sDateClass%>"><%=FormatDateTime(file.Dat eLastModified,
VBShortDate)%><%= "..." & DateDiff("n", file.DateLastModified,
sLastVisit )%></td>
</tr>
<%
End if
Next
%>
</table>
</td>
</tr>
</table>
</div>
<p>If you have any queries or you think this page is not functioning
correctly contact <%=sContact%>.</p>
</body>
</html>
CJM Guest
-
Frontend Web Servers connect to Coldfusion Servers
I need some help getting a front end web server cluster (iis) talking with the backend colfusion app cluster (j2ee install). Do I have to install... -
Datediff Problem
I am having some difficulties with the function Datediff! I am trying to calculate the number of days between two given date E.G: Number days... -
Query - Datediff problem
Hello all, I am trying to generate a list of users that have not responded to a survey in 3 months, but I am running into problems with the... -
DateDiff Problem with the Year 2000
I am having a problem calculating the proper age of people if they were born in the year 2000 <cfset bydate=#dateformat(#todaydate#,"mm/dd/yy")#>... -
Is this a problem for CF servers??
Lately I have been seeing in my server logs this: /CFIDE/main/ide.cfm CFSRV=IDE&ACTION=DBFuncs What is this visitor is trying to accomplish... -
Aaron Bertrand - MVP #2
Re: DateDiff problem on different servers
What does sLastVisit look like? This is one of the dangers of using
regional date formats, like dd/mm/yyyy or mm/dd/yyyy. When you run code
that relies on British format (dd/mm/yyyy) on a machine set up for US
English, you're going to get some funny behavior, for sure.
Wait until 2003-09-13, that's when code should start breaking on you. If
you want to fix it in the meantime, use an ISO standard date format instead
of a regional one.
"CJM" <cjmwork@yahoo.co.uk> wrote in message
news:eWPET2hdDHA.3332@TK2MSFTNGP09.phx.gbl...a> I have an ASP page that lists files and folders in a directory. I'm usingetc> cookie to record the last time this page was visited, and I intend to show
> links that are created/modified from that date minus 30mins to the
> present... eg effectively new and modified files:
>
> If DateDiff("n", subfolder.DateLastModified, sLastVisit ) < 30 Then....value>
> On my test machine this mechanism works OK, but on the live server (Win2k,
> IIS5) I get some funny behaviour.
>
> I create a new folder, and run the page. The value this expression returns
> on XP is 0 and on Win2K is 43200. Refreshing every minute...on XP thelast> increases, 1,2,3 etc... On Win2k, it decreases, 43200,43199,43198 etc....
> Folders created days ago have values like 37415
>
> The file list is similar:
>
> If DateDiff("n", file.DateLastModified, sLastVisit ) < 30 Then etc....
>
> On the Win2k m/c, a new file returns 43200 again...
>
> Am I missing something?? Do the DateDiff functions behave differently on
> different servers (ie different versions of IIS)?
>
> Help!
>
> Thanks
>
> Chris
>
>
>
>
> Bigger Code Snippet (some key settings are stored in an include file):
>
> <%@ Language=VBScript %>
> <%
> Option Explicit
> Response.Expires = 0
>
> Dim folderspec, fso, fold, subfolder, files, file, subfld
> Dim sFilter, sStartFolder, sStartPath, sTitle, sContact
> Dim aDirs, i, j , sLink
> Dim sLastVisit, sCookie, sDateClass, sMaxDiff
>
> 'Read LastVisit cookie
> sLastVisit = Request.Cookies.Item("QADocs")("LastVisit")
> If sLastVisit = "" Then
> 'sLastVisit = FormatDateTime(Now(),VBShortDate)
> sLastVisit = Now()
> End If
>
> Response.Write sLastVisit
> 'Set/Update Cookie
> 'Response.Cookies("sCookie")("LastVisit") = FormatDateTime(Now(),
> VBShortDate)
> Response.Cookies.Item("QADocs")("LastVisit") = Now()
>
> %>
> <!-- #include file="config.asp" -->
> <%
>
> 'Recover subfolder name if available
> subfld = Request.Querystring("sub")
> subfld = subfld & "/"
>
> 'create full folder path
> folderspec = Replace(sStartPath & subfld, "/", "\")
>
> %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <title><%=sTitle%></title>
> <link type='text/css' rel='stylesheet' href='Quality.css'>
> </head>
> <body>
> <div id='header'>
> <h2><%=sTitle%></h2>
> </div>
> <div id='outer'>
> <p>Note: Files or folders that have been added or modified since yourThen> visit have their dates shown <span class="new">like this.</span></p>
> <table id='tbls'>
> <tr id="breadcrumbs">
> <td colspan="2">
> <%
>
> Response.Write "<a href='./quality.asp'>" & sStartFolder & "</a>"
>
> aDirs = Split(subfld,"/")
> For i = 1 to UBound(aDirs)
> Response.Write " > <a href='"
>
> sLink = ""
> For j = 1 to i
> sLink=sLink & "/" & aDirs(j)
> Next
> Response.Write "./quality.asp?sub=" & sLink
>
> Response.Write "'>" & aDirs(i) & "</a>"
> Next
>
> %>
> </td>
> </tr>
> <tr>
> <td>
> <!-- Folders table -->
> <table class="fld">
> <colgroup class="lhs" />
> <colgroup class="rhs" />
> <tr>
> <td class="title">Folder Name</td>
> <td class="title">Last Modified</td>
> </tr>
> <%
>
> 'Create FileSystemObject
> Set fso = CreateObject("Scripting.FileSystemObject")
>
> 'Loop through Folders
> Set fold = fso.GetFolder(folderspec)
> for each subfolder in fold.subFolders
> 'ignore system or hidden folders - signified by "_"
> If Left(subfolder.name,1) <> "_" Then
> If DateDiff("n", subfolder.DateLastModified, sLastVisit ) < sMaxDiff> sDateClass = "new"
> Else
> sDateClass = ""
> End if
> %>
> <tr>
> <td><a class="folder"
> href='quality.asp?sub=<%=subfld &
> subfolder.name%>'><%=subfolder.name%>...</a></td>
> <td
> class="<%=sDateClass%>"><%=FormatDateTime(subfolde r.DateLastModified,
> VBShortDate)%><%= "..." & DateDiff("n", subfolder.DateLastModified,
> sLastVisit)%></td>
> </tr>
> <%
> End if
> next
> %>
> </table>
> </td>
> <td>
> <!-- Files table -->
> <table class="fil">
> <colgroup class="lhs" />
> <colgroup class="rhs" />
> <tr>
> <td class="title">File Name</td>
> <td class="title">Last Modified</td>
> </tr>
> <%
> 'Loop through Files
> set files = fold.files
> for each file in files
> If Instr(1, sFilter, lcase(right(file.name,3))) Then
> If DateDiff("n", file.DateLastModified, sLastVisit ) < sMaxDiff Then
> sDateClass = "new"
> Else
> sDateClass = ""
> End if
> %>
> <tr>
> <td><a class="file" href='.<%=subfld &
> file.name%>'><%=file.name%></a></td>
> <td
> class="<%=sDateClass%>"><%=FormatDateTime(file.Dat eLastModified,
> VBShortDate)%><%= "..." & DateDiff("n", file.DateLastModified,
> sLastVisit )%></td>
> </tr>
> <%
> End if
> Next
> %>
>
> </table>
> </td>
> </tr>
> </table>
> </div>
>
> <p>If you have any queries or you think this page is not functioning
> correctly contact <%=sContact%>.</p>
>
> </body>
> </html>
>
>
>
>
Aaron Bertrand - MVP Guest
-
CJM #3
Re: DateDiff problem on different servers
As ever, you are quite correct. I'll convert my dates to ISO format. Well,
I've already started actually.
However, I'm afraid this is a side issue. The problem remains.
Well I'm off on my hols for a week... I guess I'll pick this up again when I
get back....!
Cheers
Chris
"Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
news:uceDu5hdDHA.1460@TK2MSFTNGP10.phx.gbl...instead> What does sLastVisit look like? This is one of the dangers of using
> regional date formats, like dd/mm/yyyy or mm/dd/yyyy. When you run code
> that relies on British format (dd/mm/yyyy) on a machine set up for US
> English, you're going to get some funny behavior, for sure.
>
> Wait until 2003-09-13, that's when code should start breaking on you. If
> you want to fix it in the meantime, use an ISO standard date format> of a regional one.
>
>
CJM Guest
-
Jacob Yang [MSFT] #4
RE: DateDiff problem on different servers
Hi CJM,
I should say this is a weird issue. This kind of problem is seldom reported
before.
I tried the following code on my side.
---------fso.vbs-------
dim filespec
filespec = "Noname1.html"
ShowFileAccessInfo filespec
Function ShowFileAccessInfo(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
s = UCase(filespec) & "<BR>"
s = s & "Created: " & f.DateCreated & "<BR>"
s = s & "Last Accessed: " & f.DateLastAccessed & "<BR>"
s = s & "Last Modified: " & f.DateLastModified
dim sLastVisit
sLastVisit = f.DateLastModified - 1 ' set the sLastVisit to one day
before Now.
WScript.Echo DateDiff("n", f.DateLastModified, sLastVisit )
'ShowFileAccessInfo = s
End Function
--------------------------------
It works correctly on both Win2000 and WinXP. Please test my code on your
side. I certainly appreciate your time.
Best regards,
Jacob Yang
Microsoft Online Partner Support
<MCSD>
Get Secure! ¨C [url]www.microsoft.com/security[/url]
This posting is provided "as is" with no warranties and confers no rights.
Jacob Yang [MSFT] Guest
-
CJM #5
Re: DateDiff problem on different servers
Jacob,
Thanks for your reply. Soirry for the delay, I've been away...
I tried your code and it appears to work fine on both XP and Win2K machines.
I'm going to follow Aarons advice and convert my dates to ISO format at the
system boundaries, and as part of this I'll revisit my code. If I'm still
suffering problems, I'll resubmit my query.
Thanks for your help.
Chris
"Jacob Yang [MSFT]" <jiany@online.microsoft.com> wrote in message
news:$SJy2l2dDHA.2288@cpmsftngxa06.phx.gbl...reported> Hi CJM,
>
> I should say this is a weird issue. This kind of problem is seldom> before.
>
> I tried the following code on my side.
>
> ---------fso.vbs-------
> dim filespec
> filespec = "Noname1.html"
>
> ShowFileAccessInfo filespec
>
> Function ShowFileAccessInfo(filespec)
> Dim fso, f, s
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.GetFile(filespec)
> s = UCase(filespec) & "<BR>"
> s = s & "Created: " & f.DateCreated & "<BR>"
> s = s & "Last Accessed: " & f.DateLastAccessed & "<BR>"
> s = s & "Last Modified: " & f.DateLastModified
>
> dim sLastVisit
>
> sLastVisit = f.DateLastModified - 1 ' set the sLastVisit to one day
> before Now.
>
> WScript.Echo DateDiff("n", f.DateLastModified, sLastVisit )
>
> 'ShowFileAccessInfo = s
> End Function
> --------------------------------
>
> It works correctly on both Win2000 and WinXP. Please test my code on your
> side. I certainly appreciate your time.
>
> Best regards,
>
> Jacob Yang
> Microsoft Online Partner Support
> <MCSD>
> Get Secure! ¨C [url]www.microsoft.com/security[/url]
> This posting is provided "as is" with no warranties and confers no rights.
>
CJM Guest



Reply With Quote

