[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

08/09/2006 at 12:04AM PDT, ID: 21948013
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Date query not working - US VS Aus date format issue

Asked by RascalBird in Active Server Pages (ASP)

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("fromfld")) != "undefined" &&
    String(Request.Form("fromfld")) != "") {
  rsdates__fromfld = String(Request.Form("fromfld"));
}
%>
<%
var rsdates__tofld = "1/1/2006";
if (String(Request.Form("tofld")) != "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__fromfld);
%>

<%
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.Source);
//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.
[+][-]08/09/06 12:37 AM, ID: 17277057

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/09/06 02:30 AM, ID: 17277490

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/09/06 03:27 PM, ID: 17283542

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/09/06 04:33 PM, ID: 17283887

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/09/06 09:44 PM, ID: 17285157

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/07/06 02:08 PM, ID: 17474734

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09/11/06 03:11 AM, ID: 17493072

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Sign Up Now!
Solution Provided By: CetusMOD
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20090824-EE-VQP-74