 |
|
 |
|
Next: DCOM config for Isolated websites (was "IIS ..
|
| Author |
Message |
External

Since: Sep 08, 2003 Posts: 34
|
(Msg. 1) Posted: Mon Sep 08, 2003 7:29 pm
Post subject: DateDiff problem on different servers Archived from groups: microsoft>public>inetserver>asp>general, others (more info?)
|
|
|
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(subfolder.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.DateLastModified,
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> >> Stay informed about: DateDiff problem on different servers |
|
| Back to top |
|
 |  |
External

Since: Sep 08, 2003 Posts: 7
|
(Msg. 2) Posted: Mon Sep 08, 2003 7:29 pm
Post subject: Re: DateDiff problem on different servers [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
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 DeleteThis @yahoo.co.uk> wrote in message
news:eWPET2hdDHA.3332@TK2MSFTNGP09.phx.gbl...
> 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 "" & sStartFolder & ""
>
> 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(subfolder.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.DateLastModified,
> 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>
>
>
>
><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: DateDiff problem on different servers |
|
| Back to top |
|
 |  |
External

Since: Sep 08, 2003 Posts: 34
|
(Msg. 3) Posted: Mon Sep 08, 2003 8:31 pm
Post subject: Re: DateDiff problem on different servers [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
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 RemoveThis @TRASHaspfaq.com> wrote in message
news:uceDu5hdDHA.1460@TK2MSFTNGP10.phx.gbl...
> 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.
>
><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: DateDiff problem on different servers |
|
| Back to top |
|
 |  |
| Related Topics: | Replication of content across servers in a web farm - Been looking for some info on the techniques/tools you are using to replicate content across all servers in your web farms. The farm runs with Windows 2003 (Web Server edition) servers. The designers are uploading images/PDFs thru FTP access all the..
IIS Problem - DQpIaSwNCg0Kd2UgaGF2ZSBzZXJpb3VzbHkgSUlTIHByb2JsZW0gd2UgY2FuIG5vdCBzb2x2ZS4g V2UgZ290IGV2ZW50IGlkIDM3LCBPdXQgb2YgcHJvY2VzcyBhcHBsaWNhdGlvbiAnL0xNL1czU1ZD LyMjIy9Sb290JyB0ZXJtaW5hdGVkIHVuZXhwZWN0ZWRseS4gQXNwIHJlcG9ydCBSUEMgcHJvYmxl..
i have a problem - when i am sending email to my SMTP server it is sent but its staying in the Queue directory and dont go out to the email address help me
Help Please: installation problem with IIS - Hello, I appreciate any help: After I installed IIS 5.1 on my XP Pro. and when I opened it I realized the 'Default Web Site' in the Web Sites folder shows a red error icon, and when I start the web site I get the error "Unexpected error 0x8ffe2740....
Problem reinstalling IIS - Hey, I hope that someone can help me with my IIS problem. Ive just reinstalled IIS but the folders inetpub/wwwroot is not created. Internet Information Services dosent show in Administrative Tools either. Ive done this a few times now but only with sam... |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|