Date Range Search Using MySQL (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


sentinel -> Date Range Search Using MySQL (10/26/2005 14:51:05)

hey all...

I have a form page with 2 fields. StartDate and EndDate

i have a FPDRW on the spooky diet that is fed from those two fields.

I have the form page submitting to itself because the fpdrw is right below the form fields.

When i try to pass it start and end dates it does not do anything.

The field datatype i am using is DATE.

Here is my code

<form method="POST" action="hc_super_call_log_main2.asp">
              <p align="center">
              <input type="text" name="startdate" size="20">
              <input type="text" name="enddate" size="20"></p>
              <p align="center"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
            </form>
            <table width="100%" border="1" height="94">
              <thead>
                <tr>
                  <td height="19"><b>datetime</b></td>
                </tr>
              </thead>
              <tbody>
                <!--#include file="_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
                </SCRIPT>
<% end if %>
<%
fp_sQry="SELECT datetime FROM hc_call_log  WHERE datetime Between '"  & request.form("datetime" ) & "'   And  '" & request.form("datetime" ) & "' "
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=1 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Database1"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="datetime"
fp_sMenuValue="datetime"
fp_sColTypes="&datetime=133&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=2
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<tr>
                  <td height="19">
                  <%=FP_FieldVal(fp_rs,"datetime")%></td>
                </tr>
                <!--#include file="_fpclass/fpdbrgn2.inc"-->


Any ideas?




rdouglass -> RE: Date Range Search Using MySQL (10/26/2005 15:15:42)

quote:

fp_sQry="SELECT datetime FROM hc_call_log WHERE datetime Between '" & request.form("datetime" ) & "' And '" & request.form("datetime" ) & "' "


Not sure but datetime may be a reserved word. Have you tried something like this:

fp_sQry="SELECT [datetime] FROM hc_call_log WHERE [datetime] Between '" & request.form("datetime" ) & "' And '" & request.form("datetime" ) & "' "




sentinel -> RE: Date Range Search Using MySQL (10/26/2005 15:33:11)

Putting the datetime in [datetime] generates an error.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[datetime] FROM hc_call_log WHERE datetime Between '10/21/2005' And '10/26/2005'' at line 1




sentinel -> RE: Date Range Search Using MySQL (10/26/2005 15:37:12)

I removed the [ ] and it works awesome!

The only problem is that when I go to submit the start and end dates i need to use this format

YYYY-MM-DD

is there anyway to make it MM/DD/YYYY ?




rdouglass -> RE: Date Range Search Using MySQL (10/26/2005 15:47:51)

I think you can with the GET_FORMAT (DATE, 'USA') command. See:

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875