ASP Help

ASP Help

am 19.05.2005 17:40:21 von Kaushik Mandal

I am having a some problem with ASP reports. When I try to get the
information for specific date ranges from the asp page it gives one day
less than end date. For example if I want information from 05/02/2005 to
05/07/2005 the report only show the information from 05/002/2005 to
05/06/2005 one day less. I need to have it fixed and wonder if any one
can help me . Here is my code

Thanks

<% @ Language=VBScript %>
<% Response.Buffer = "True" %>
<%

Const PAGE_SIZE = 25
%>

<%
Dim strURL, MyLinks, RS, strSQL, strSearch, iPageCurrent, iPageCount,
iRecordCount, I, begin_date, end_date
begin_date = Request.QueryString("begin_date")
end_date = Request.QueryString("end_date")
strURL = Request.ServerVariables("URL")
code = Request.QueryString("code")
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
Set MyLinks = Server.CreateObject("ADODB.Connection")
MyLinks.Open "PROVIDER=SQLOLEDB;DATA
SOURCE=DREVIL;UID=web;PWD=secret;DATABASE=ivm_repo rts"
strSQL = "SELECT Employee, Empno, convert(varchar(10),Date,101)as Date,
Time, Machine, Amount, Description,itemnumber,TCost FROM QryEmpUsage
WHERE UserName = '" & Request.Querystring("code") & "' AND
QryEmpUsage.Date BETWEEN '" & begin_date & "' AND '" & end_date &
"'order by date "
Set RS = Server.CreateObject("ADODB.Recordset")
RS.PageSize = PAGE_SIZE
RS.CacheSize = PAGE_SIZE
RS.Open strSQL, MyLinks, adOpenStatic, adLockReadOnly
iRecordCount = RS.RecordCount
iPageCount = RS.PageCount
SelectStatement = strSQL
ReportsName = "Employee Usage"

%>





International Vending Management--Employee Usage Report






















valign="bottom">

| PPE
Menu
| | href="corp_login.asp">Corporate Login | Location
Login
|
src="images/ppe_employee_usage_report.gif">


href="print.asp?code=<%=code%>&ReportsName=<%=ReportsName%>&Select=<%=Tr
im(SelectStatement)%>">Printer Friendly Version















<%
If Request.QueryString("begin_date") <> "" Then
If iRecordCount = 0 Then
Response.Redirect("info.asp?event=norec&page=employeeusage.a sp?code=" &
code)
Else
RS.AbsolutePage = iPageCurrent
bgcolor="#A4BEEA"
Do While Not RS.EOF and RS.AbsolutePage = iPageCurrent
%>












<%
If bgcolor="#A4BEEA" Then
bgcolor="#8EABDD"
Else
bgcolor="#A4BEEA"
End If
RS.MoveNext
Loop
%>




<%
End If
%>

color="#ffffff">
type="hidden" name="code" value="<%=code%>">
Begin Date: End
Date: type="submit" value="Go">
Begin Date : <%=begin_date%> End Date <%=end_date%>

<%=iRecordCount%> Records Found. Displaying page <%=iPageCurrent %> of
<%=iPageCount %>
COLOR="#A4BEEA">Employee COLOR="#A4BEEA">Empno COLOR="#A4BEEA">Date COLOR="#A4BEEA">Time COLOR="#A4BEEA">Machine COLOR="#A4BEEA">Amount COLOR="#A4BEEA">Description COLOR="#A4BEEA">Item Number COLOR="#A4BEEA">Cost
face="verdana,arial,helvetica"
color="#13215F"><%=Trim(RS("Employee"))%>
face="verdana,arial,helvetica"
color="#13215F"><%=Trim(RS("EmpNo"))%>
face="verdana,arial,helvetica"
color="#13215F"><%=TRIM(RS("Date"))%>
face="verdana,arial,helvetica"
color="#13215F"><%=Trim(RS("Time"))%>
face="verdana,arial,helvetica"
color="#13215F"><%=Trim(RS("Machine"))%>
face="verdana,arial,helvetica"
color="#13215F"><%=Trim(RS("Amount"))%>
face="verdana,arial,helvetica"
color="#13215F"><%=Trim(RS("Description"))%>
face="verdana,arial,helvetica"
color="#13215F"><%=Trim(RS("Itemnumber"))%>
face="verdana,arial,helvetica"
color="#13215F"><%=FormatCurrency(Trim(RS("TCost")),2)%>

<%
If iPageCurrent > 1 Then
%>

[<< Prev]
<%
End If
%>
<%
For I = 1 To iPageCount
If I = iPageCurrent Then
%>

<%= I %>
<%
Else
%>

href="<%=strURL%>?code=<%=code%>&page=<%=I%>&begin_date=<%=begin_date%>&
end_date=<%=end_date%>"><%=I%>
<%
End If
Next
%>

<%
If iPageCurrent < iPageCount Then
%>

[Next >>]
<%
End If
End If
If begin_date <> "" Then
RS.Close
Set RS = Nothing
MyLinks.Close
Set MyLinks = Nothing
End If
Else
%>









*** Sent via Developersdex http://www.developersdex.com ***

Re: ASP Help

am 19.05.2005 19:13:02 von rdanjou

This is because that probably QryEmpUsage.Date contains a time part and your
parameters have none.
In this case, the time portion defaults to 00:00:00.
Most people here prefer, for dates, to use < and >.

>= '" & begin_date & "' AND QryEmpUsage.Date < '" & end_date &

"Kaushik Mandal" wrote in message
news:OiSJSkIXFHA.3448@TK2MSFTNGP10.phx.gbl...
>
> I am having a some problem with ASP reports. When I try to get the
> information for specific date ranges from the asp page it gives one day
> less than end date. For example if I want information from 05/02/2005 to
> 05/07/2005 the report only show the information from 05/002/2005 to
> 05/06/2005 one day less. I need to have it fixed and wonder if any one
> can help me . Here is my code
>
> Thanks
>
> <% @ Language=VBScript %>
> <% Response.Buffer = "True" %>
> <%
>
> Const PAGE_SIZE = 25
> %>
>
> <%
> Dim strURL, MyLinks, RS, strSQL, strSearch, iPageCurrent, iPageCount,
> iRecordCount, I, begin_date, end_date
> begin_date = Request.QueryString("begin_date")
> end_date = Request.QueryString("end_date")
> strURL = Request.ServerVariables("URL")
> code = Request.QueryString("code")
> If Request.QueryString("page") = "" Then
> iPageCurrent = 1
> Else
> iPageCurrent = CInt(Request.QueryString("page"))
> End If
> Set MyLinks = Server.CreateObject("ADODB.Connection")
> MyLinks.Open "PROVIDER=SQLOLEDB;DATA
> SOURCE=DREVIL;UID=web;PWD=secret;DATABASE=ivm_repo rts"
> strSQL = "SELECT Employee, Empno, convert(varchar(10),Date,101)as Date,
> Time, Machine, Amount, Description,itemnumber,TCost FROM QryEmpUsage
> WHERE UserName = '" & Request.Querystring("code") & "' AND
> QryEmpUsage.Date BETWEEN '" & begin_date & "' AND '" & end_date &
> "'order by date "
> Set RS = Server.CreateObject("ADODB.Recordset")
> RS.PageSize = PAGE_SIZE
> RS.CacheSize = PAGE_SIZE
> RS.Open strSQL, MyLinks, adOpenStatic, adLockReadOnly
> iRecordCount = RS.RecordCount
> iPageCount = RS.PageCount
> SelectStatement = strSQL
> ReportsName = "Employee Usage"
>
> %>
>
>
>
>
>
> International Vending Management--Employee Usage Report
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> valign="bottom">

> | PPE
> Menu
| | > href="corp_login.asp">Corporate Login | Location
> Login
|
> src="images/ppe_employee_usage_report.gif">

>
> > href="print.asp?code=<%=code%>&ReportsName=<%=ReportsName%>&Select=<%=Tr
> im(SelectStatement)%>">Printer Friendly Version

>
>
>
>
>
>
>
>
>
>
>
>
>
>
> <%
> If Request.QueryString("begin_date") <> "" Then
> If iRecordCount = 0 Then
> Response.Redirect("info.asp?event=norec&page=employeeusage.a sp?code=" &
> code)
> Else
> RS.AbsolutePage = iPageCurrent
> bgcolor="#A4BEEA"
> Do While Not RS.EOF and RS.AbsolutePage = iPageCurrent
> %>
>
>
>
>
>
>
>
>
>
>
>
>
> <%
> If bgcolor="#A4BEEA" Then
> bgcolor="#8EABDD"
> Else
> bgcolor="#A4BEEA"
> End If
> RS.MoveNext
> Loop
> %>
>
>
>
>
> <%
> End If
> %>
>
>
> color="#ffffff">
> type="hidden" name="code" value="<%=code%>">
> Begin Date: End
> Date: > type="submit" value="Go">
> Begin Date : <%=begin_date%> End Date <%=end_date%>

> <%=iRecordCount%> Records Found. Displaying page <%=iPageCurrent %> of
> <%=iPageCount %>
>
> COLOR="#A4BEEA">Employee > COLOR="#A4BEEA">Empno > COLOR="#A4BEEA">Date > COLOR="#A4BEEA">Time > COLOR="#A4BEEA">Machine > COLOR="#A4BEEA">Amount > COLOR="#A4BEEA">Description > COLOR="#A4BEEA">Item Number > COLOR="#A4BEEA">Cost
> face="verdana,arial,helvetica"
> color="#13215F"><%=Trim(RS("Employee"))%>
> face="verdana,arial,helvetica"
> color="#13215F"><%=Trim(RS("EmpNo"))%>
> face="verdana,arial,helvetica"
> color="#13215F"><%=TRIM(RS("Date"))%>
> face="verdana,arial,helvetica"
> color="#13215F"><%=Trim(RS("Time"))%>
> face="verdana,arial,helvetica"
> color="#13215F"><%=Trim(RS("Machine"))%>
> face="verdana,arial,helvetica"
> color="#13215F"><%=Trim(RS("Amount"))%>
> face="verdana,arial,helvetica"
> color="#13215F"><%=Trim(RS("Description"))%>
> face="verdana,arial,helvetica"
> color="#13215F"><%=Trim(RS("Itemnumber"))%>
> face="verdana,arial,helvetica"
> color="#13215F"><%=FormatCurrency(Trim(RS("TCost")),2)%>

> <%
> If iPageCurrent > 1 Then
> %>
>
> [<< Prev]
> <%
> End If
> %>
> <%
> For I = 1 To iPageCount
> If I = iPageCurrent Then
> %>
>
> <%= I %>
> <%
> Else
> %>
>
> > href="<%=strURL%>?code=<%=code%>&page=<%=I%>&begin_date=<%=begin_date%>&
> end_date=<%=end_date%>"><%=I%>
> <%
> End If
> Next
> %>
>
> <%
> If iPageCurrent < iPageCount Then
> %>
>
> [Next >>]
> <%
> End If
> End If
> If begin_date <> "" Then
> RS.Close
> Set RS = Nothing
> MyLinks.Close
> Set MyLinks = Nothing
> End If
> Else
> %>
>

>

>
>
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***