开发者

If a > 0 or a = 0 & b < 0 or b = 0 Statement isn't working how it should be

I'm new to ASP (new job uses a windows server and I've only used Linux before) and I'm building a 'log' that stores it's data into XML files. I've got it reading the XML out perfectly but now I'm trying to get it to print out data from a specific range of dates.

The way I'm doing this is by using the DateDiff function to compare the date in the XML entry to the date the user defines, this will then output a number. If this number is greater than 1 for the start date and less than one for the end date then it will be displayed. The startdate part works but no matter what date I put in the end date it will just print everything from the startdate upwards.

Here's my code

<%
Response.Buffer = True
session.lcid=2057
Set entries = Server.CreateObject("Microsoft.XMLDOM")
Set entry = Server.CreateObject("Microsoft.XMLDOM")
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("log.xml"))

set entries = xml.getElementsbyTagName("entry")

noOfEntries = entries.length
If Request.Form("findLog") = "true" Th开发者_如何学Cen
    CheckLog
End If
%>
<html>
<head>
<title>GM Log</title>
</head>
<body>
<p>Please enter the dates that you want to view the log from</p>
<form name=form1 action=readlog.asp method=post>
<p>Start date: <input type=text name=startdate>End date: <input type=text name=enddate>
<input type=hidden name=findLog value=true>  <input type=submit value="Search"></p>

</form>

<%
Sub CheckLog 
     startDate = Request.Form("startdate")
     LastDate = Request.Form("enddate")
     Response.Write("<table border=5>")
     For i = 0 To (noOfEntries - 1)
         Set entry = entries.item(i)
         If isDate(entry.childNodes(0).text) Then
             meh = CDate(entry.childNodes(0).text)
             beginning = DateDiff("d", startDate, meh)
             Response.Write ("<p style=""color: red"">days from startdate: " & beginning & "</p>")
             ended = DateDiff("d", LastDate, meh)
             Response.Write ("<p>days from today: " & ended & "</p>")
             If beginning + 1 > 0 or beginning + 1 = 0 & ended < 0 or ended = 0 Then
          Response.Write("<tr>"&_
 "<td>" & entry.childNodes(0).text & "</td>"&_
 "<td>" & entry.childNodes(1).text & "</td>"&_
 "<td>" & entry.childNodes(2).text & "</td>"&_
 "<td>" & entry.childNodes(3).text & "</td>"&_
 "<td>" & entry.childNodes(4).text & "</td>"&_
 "</tr>")
             End If
       End If  

    Next
    Response.Write("<table>")
End Sub
%>

</body>
</html>

Here's my XML file layout.

<?xml version="1.0"?>
<GM>
    <entry>
         <date>15/07/2010</date>
         <time>1515</time>
          <conversation>Dave down the Pub</conversation>
          <information>This is another test.</information>
          <action>Colin Wren</action>
     </entry>
     <entry>
          <date>20/07/2010</date>
          <time>1700</time>
          <conversation>Sam</conversation>
          <information>this is a test</information>
          <action>Colin</action>
    </entry>
</GM>

I'm sure it's just me being stupid and frying my brain looking at it too long but any help would be really appreciated.


Maybe you want the following?

If beginning + 1 >= 0 And ended <= 0 Then

Note that for a logical AND operation in VB you will have to use the And operator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜