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.DateL astModified, 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,431 98 etc....
Folders created days ago have values like 37415
The file list is similar:
If DateDiff("n", file.DateLastMo dified, 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=VBScri pt %>
<%
Option Explicit
Response.Expire s = 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(),VBShortDa te)
sLastVisit = Now()
End If
Response.Write sLastVisit
'Set/Update Cookie
'Response.Cooki es("sCookie")(" LastVisit") = FormatDateTime( Now(),
VBShortDate)
Response.Cookie s.Item("QADocs" )("LastVisit" ) = Now()
%>
<!-- #include file="config.as p" -->
<%
'Recover subfolder name if available
subfld = Request.Queryst ring("sub")
subfld = subfld & "/"
'create full folder path
folderspec = Replace(sStartP ath & subfld, "/", "\")
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><%=sTitl e%></title>
<link type='text/css' rel='stylesheet ' href='Quality.c ss'>
</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">lik e 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">F older Name</td>
<td class="title">L ast Modified</td>
</tr>
<%
'Create FileSystemObjec t
Set fso = CreateObject("S cripting.FileSy stemObject")
'Loop through Folders
Set fold = fso.GetFolder(f olderspec)
for each subfolder in fold.subFolders
'ignore system or hidden folders - signified by "_"
If Left(subfolder. name,1) <> "_" Then
If DateDiff("n", subfolder.DateL astModified, sLastVisit ) < sMaxDiff Then
sDateClass = "new"
Else
sDateClass = ""
End if
%>
<tr>
<td><a class="folder"
href='quality.a sp?sub=<%=subfl d &
subfolder.name% >'><%=subfolder .name%>...</a></td>
<td
class="<%=sDate Class%>"><%=For matDateTime(sub folder.DateLast Modified,
VBShortDate)%>< %= "..." & DateDiff("n", subfolder.DateL astModified,
sLastVisit)%></td>
</tr>
<%
End if
next
%>
</table>
</td>
<td>
<!-- Files table -->
<table class="fil">
<colgroup class="lhs" />
<colgroup class="rhs" />
<tr>
<td class="title">F ile Name</td>
<td class="title">L ast Modified</td>
</tr>
<%
'Loop through Files
set files = fold.files
for each file in files
If Instr(1, sFilter, lcase(right(fil e.name,3))) Then
If DateDiff("n", file.DateLastMo dified, sLastVisit ) < sMaxDiff Then
sDateClass = "new"
Else
sDateClass = ""
End if
%>
<tr>
<td><a class="file" href='.<%=subfl d &
file.name%>'><% =file.name%></a></td>
<td
class="<%=sDate Class%>"><%=For matDateTime(fil e.DateLastModif ied,
VBShortDate)%>< %= "..." & DateDiff("n", file.DateLastMo dified,
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> 4 4092
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" <cj*****@yahoo. co.uk> wrote in message
news:eW******** ******@TK2MSFTN GP09.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.DateL astModified, 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,431 98 etc.... Folders created days ago have values like 37415
The file list is similar:
If DateDiff("n", file.DateLastMo dified, 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=VBScri pt %> <% Option Explicit Response.Expire s = 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(),VBShortDa te) sLastVisit = Now() End If
Response.Write sLastVisit 'Set/Update Cookie 'Response.Cooki es("sCookie")(" LastVisit") = FormatDateTime( Now(), VBShortDate) Response.Cookie s.Item("QADocs" )("LastVisit" ) = Now()
%> <!-- #include file="config.as p" --> <%
'Recover subfolder name if available subfld = Request.Queryst ring("sub") subfld = subfld & "/"
'create full folder path folderspec = Replace(sStartP ath & subfld, "/", "\")
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title><%=sTitl e%></title> <link type='text/css' rel='stylesheet ' href='Quality.c ss'> </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">lik e 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">F older Name</td> <td class="title">L ast Modified</td> </tr> <%
'Create FileSystemObjec t Set fso = CreateObject("S cripting.FileSy stemObject")
'Loop through Folders Set fold = fso.GetFolder(f olderspec) for each subfolder in fold.subFolders 'ignore system or hidden folders - signified by "_" If Left(subfolder. name,1) <> "_" Then If DateDiff("n", subfolder.DateL astModified, sLastVisit ) < sMaxDiff
Then sDateClass = "new" Else sDateClass = "" End if %> <tr> <td><a class="folder" href='quality.a sp?sub=<%=subfl d & subfolder.name% >'><%=subfolder .name%>...</a></td> <td class="<%=sDate Class%>"><%=For matDateTime(sub folder.DateLast Modified, VBShortDate)%>< %= "..." & DateDiff("n", subfolder.DateL astModified, sLastVisit)%></td> </tr> <% End if next %> </table> </td> <td> <!-- Files table --> <table class="fil"> <colgroup class="lhs" /> <colgroup class="rhs" /> <tr> <td class="title">F ile Name</td> <td class="title">L ast Modified</td> </tr> <% 'Loop through Files set files = fold.files for each file in files If Instr(1, sFilter, lcase(right(fil e.name,3))) Then If DateDiff("n", file.DateLastMo dified, sLastVisit ) < sMaxDiff Then sDateClass = "new" Else sDateClass = "" End if %> <tr> <td><a class="file" href='.<%=subfl d & file.name%>'><% =file.name%></a></td> <td class="<%=sDate Class%>"><%=For matDateTime(fil e.DateLastModif ied, VBShortDate)%>< %= "..." & DateDiff("n", file.DateLastMo dified, 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>
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" <aa***@TRASHasp faq.com> wrote in message
news:uc******** ******@TK2MSFTN GP10.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.
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.ht ml"
ShowFileAccessI nfo filespec
Function ShowFileAccessI nfo(filespec)
Dim fso, f, s
Set fso = CreateObject("S cripting.FileSy stemObject")
Set f = fso.GetFile(fil espec)
s = UCase(filespec) & "<BR>"
s = s & "Created: " & f.DateCreated & "<BR>"
s = s & "Last Accessed: " & f.DateLastAcces sed & "<BR>"
s = s & "Last Modified: " & f.DateLastModif ied
dim sLastVisit
sLastVisit = f.DateLastModif ied - 1 ' set the sLastVisit to one day
before Now.
WScript.Echo DateDiff("n", f.DateLastModif ied, sLastVisit )
'ShowFileAccess Info = 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 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
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]" <ji***@online.m icrosoft.com> wrote in message
news:$S******** ******@cpmsftng xa06.phx.gbl... 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.ht ml"
ShowFileAccessI nfo filespec
Function ShowFileAccessI nfo(filespec) Dim fso, f, s Set fso = CreateObject("S cripting.FileSy stemObject") Set f = fso.GetFile(fil espec) s = UCase(filespec) & "<BR>" s = s & "Created: " & f.DateCreated & "<BR>" s = s & "Last Accessed: " & f.DateLastAcces sed & "<BR>" s = s & "Last Modified: " & f.DateLastModif ied
dim sLastVisit
sLastVisit = f.DateLastModif ied - 1 ' set the sLastVisit to one day before Now.
WScript.Echo DateDiff("n", f.DateLastModif ied, sLastVisit )
'ShowFileAccess Info = 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 www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tim::. |
last post by:
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 between 03-05-2004 and 05-05-2004 =
I am using the following piece of asp to extract dates from an XML document and work with them to create the above mentioned result, however I can't get it to work
Can someone please assist!
Thank
|
by: inamori |
last post by:
I face that problems
07/01/2003 06/30/2006 ---------> it should be 3
01/01/2003 02/28/2005 --------->could i get 2 years and 2 months
01/01/2003 03/01/2005 --------->could i get 2 years and 2 months and 1
|
by: John Smith |
last post by:
Hi,
I'm having trouble working out the best way of calculating the time
difference between two times on the same day.
The example I have found does return the hours (in this case 8) but forgets
the minutes.
I am looking to return the hour & the minute but i've had a look at the
dateDiff format and this doesn't seem possible ?
|
by: Paolo |
last post by:
I am having some problem with a Year Function.
I have form on which I have 4 field which indicate dates and an
additional form which sums those dates:
These are the fields:
YEARS
STARTINGDATE1
ENDINGDATE1
STARTINGDATE2
|
by: mcbill20 |
last post by:
Hello all. I have a really basic question that I hope someone has a
better answer for. I apologize in advance-- I know this is probably a
really basic question but I am used to Oracle rathern than Access.
I have a database where they customer wants to purge records from
certain tables after three years. When I was asked to make the changes
I originally thought this was an incredibly simple thing to do. I
looked at the function list and...
| |
by: Dean Earley |
last post by:
I have the following code to get the number of seconds into a day given
a date/time value:
TValS = DateDiff("s", DateValue(StillDate), StillDate)
StillDate is #04/05/2006 21:03:52#, and DateValue is correct at
#04/05/2006# yet TValS is giving me -2429768 (Yes, negative 2.4 million)
This only occurs on 3 machines we've seen so far (none we have direct
access to)
|
by: OdAwG |
last post by:
Hello Again Access GURU's,
Need some help with Conditional Formatting and datediff. What I am trying
to do is the following:
I have three text boxes with dates in them and what I want to do is change
the background color if the date in the text box get within a certain date
range.
Date Range:
|
by: StevoNZ |
last post by:
Hi,
I am a little stuck with a query I am trying to build. Attemting to calculate the delivery time for a material.
I have managed to utilise the DateDiff function, but have some additional complexities.
1. The dates I am using are to calculate a more correct delivery time is not always populated, therefore I need to utilise a different date field.
DateDiff("d",DTMORD,DATREC) AS Expr1
DateDiff("d",DTMORL,DATREC) AS Expr2
|
by: geraldinegrieve |
last post by:
I have a table in access that holds data on vehicle there are 3 fields holding dates on MOT, Tax and Insurance renewal I am looking for 3 different messages on opening if date of any is within next 2 weeks e.g.
If DateDiff("d", Me.MOT_Renewal_Date, Now()) < 15 Then
MsgBox "Vehicles Due MOT Renewal", , "Renewal Due"
If DateDiff("d", Me.Tax_Renewal_Date, Now()) < 15 Then
MsgBox "Vehicles Due Tax Renewal", , "Renewal Due"
If...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |