Hi All
I've been swearing at this trying to get it working for a few hours now. I'm trying to get a query working where the user enters a start and end date (tofld and fromfld) into the form then when they submit the query a list of results within that date range appears.
Unfortunately it worked beautifully during July but decided to stop working when we came to August - which is when I worked out that it is passing the date requests in US date format rather than Australian.
Below is my code and any help would be greatly appreciated - I'm sure its something small and stupid.
I'm using ASP/Javascript with an Access DB in the back end (I know, I hide my head in shame)
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
-
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/itreqdb.
asp" -->
<% Session.LCID=3081 %>
<%
var rsdates__fromfld = "1/1/2006";
if (String(Request.Form("from
fld")) != "undefined" &&
String(Request.Form("fromf
ld")) != "") {
rsdates__fromfld = String(Request.Form("fromf
ld"));
}
%>
<%
var rsdates__tofld = "1/1/2006";
if (String(Request.Form("tofl
d")) != "undefined" &&
String(Request.Form("tofld
")) != "") {
rsdates__tofld = String(Request.Form("tofld
"));
}
%>
<script type="text/javascript" language="javascript" runat="server">
function MediumDate(str)
{
var d = new String(Day(str));
var m = String;
var y = String;
d = Day(str);
m = Monthname(Month(str),true)
;
y = Year(str);
return d + "-" + m + "-" + y;
}
</script>
<%
rsdates__tofld = MediumDate(rsdates__tofld)
;
rsdates__fromfld = MediumDate(rsdates__fromfl
d);
%>
<%
var rsdates = Server.CreateObject("ADODB
.Recordset
");
rsdates.ActiveConnection = MM_itreqdb_STRING;
rsdates.Source = "SELECT reqid, DateClosed FROM closedata WHERE DateClosed BETWEEN #"+ rsdates__fromfld.replace(/
'/g, "''") + "# AND #"+ rsdates__tofld.replace(/'/
g, "''") + "#";
Response.Write(rsdates.Sou
rce);
//Response.End();
rsdates.CursorType = 0;
rsdates.CursorLocation = 2;
rsdates.LockType = 1;
rsdates.Open();
var rsdates_numRows = 0;
%>
<%
var Repeat1__numRows = -1;
var Repeat1__index = 0;
rsdates_numRows += Repeat1__numRows;
%>
<%
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
// set the record count
var rsdates_total = rsdates.RecordCount;
// set the number of rows displayed on this page
if (rsdates_numRows < 0) { // if repeat region set to all records
rsdates_numRows = rsdates_total;
} else if (rsdates_numRows == 0) { // if no repeat regions
rsdates_numRows = 1;
}
// set the first and last displayed record
var rsdates_first = 1;
var rsdates_last = rsdates_first + rsdates_numRows - 1;
// if we have the correct record count, check the other stats
if (rsdates_total != -1) {
rsdates_numRows = Math.min(rsdates_numRows, rsdates_total);
rsdates_first = Math.min(rsdates_first, rsdates_total);
rsdates_last = Math.min(rsdates_last, rsdates_total);
}
%>
<%
// *** Recordset Stats: if we don't know the record count, manually count them
if (rsdates_total == -1) {
// count the total records by iterating through the recordset
for (rsdates_total=0; !rsdates.EOF; rsdates.MoveNext()) {
rsdates_total++;
}
// reset the cursor to the beginning
if (rsdates.CursorType > 0) {
if (!rsdates.BOF) rsdates.MoveFirst();
} else {
rsdates.Requery();
}
// set the number of rows displayed on this page
if (rsdates_numRows < 0 || rsdates_numRows > rsdates_total) {
rsdates_numRows = rsdates_total;
}
// set the first and last displayed record
rsdates_last = Math.min(rsdates_first + rsdates_numRows - 1, rsdates_total);
rsdates_first = Math.min(rsdates_first, rsdates_total);
}
%>
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
-----
I've un-commented the function code because I *think* I need it for this to work however it comes up with Object Expected errors on the line of the first variable.
When I comment out this code when I enter the dates as 1/8/2006 and 6/8/2006 (correct format for me) I get no results. If however I enter the dates in the US format (backwards for me) of 8/1/2006 and 8/6/2006 I get the appropriate results.