D
Dooza
I have been trying to follow the recent posts about the date format. I
am building a single page report, which displays 4 columns from the
database. There are 3 filters, one is location, and the other 2 are
dates, a from and a to. When the page first loads it will show no
records, but when submitted to itself it will filter the records returned.
I am using ASP with VBScript. My database is SQL 2000 server.
I have a Stored Procedure:
ALTER PROCEDURE [dbo].[OutstandingPurchaseOrderReport]
-- Add the parameters for the stored procedure here
@Location varchar(7),
@From datetime,
@To datetime
AS
BEGIN
SELECT TOP 100 PERCENT dbo.purchaseorder.poh_order AS PONumber,
dbo.purchaseorder.poh_vendor + ' ' + dbo.vendor.vnd_name AS Vendor,
dbo.purchaseorder.poh_buyer AS Buyer,
dbo.purchaseorder.poh_orderdate AS OrderDate
FROM dbo.plannerbuyer RIGHT OUTER JOIN
dbo.purchaseorder INNER JOIN
dbo.vendor ON dbo.purchaseorder.poh_vendor =
dbo.vendor.vnd_vendor ON
dbo.plannerbuyer.plb_plannerbuyer =
dbo.purchaseorder.poh_buyer
WHERE (dbo.purchaseorder.poh_orderstatus = 'Open') AND
(dbo.plannerbuyer.plb_phonearea = CASE WHEN
@Location = 'Leeds' THEN '113' WHEN @Location = 'Wycombe' THEN '1494'
WHEN @Location = 'Both' THEN '%' END) AND
dbo.purchaseorder.poh_orderdate BETWEEN @From AND @To
ORDER BY OrderDate, PONumber
END
It takes 3 inputs from an ASP page, location, from date and to date. As
the last 2 are using datetime as the format, and the columns are
datatime, I assumed (from reading posts here) that I should be using the
ISO standard for date. Is this assumption correct?
To test my SP I did this:
EXEC OutstandingPurchaseOrderReport 'Wycombe','01/01/2001','01/01/2005'
My results:
1230002864 RAP107 Rapid Electronics Limited ANDYB 2004-02-12 00:00:00.000
1230008306 HIG1 High End Systems Inc CALLYB 2004-09-16 00:00:00.000
I also tried this EXEC OutstandingPurchaseOrderReport
'Wycombe','2004-02-12 00:00:00.000','2004-02-12 00:00:00.000'
And got exactly the same results. I am using Server Management Studio
Express, I don't know if that makes any difference.
Now on to the page itself:
<%
Dim ospo__Location
ospo__Location = "Both"
If (Request.Form("Location") <> "") Then
ospo__Location = Request.Form("Location")
End If
%>
<%
Dim ospo__From
ospo__From = "01/01/2000"
If (Request.Form("From") <> "") Then
ospo__From = Request.Form("From")
End If
%>
<%
Dim ospo__To
ospo__To = "01/01/2010"
If (Request.Form("To") <> "") Then
ospo__To = Request.Form("To")
End If
%>
<%
Dim ospo
Dim ospo_cmd
Dim ospo_numRows
Set ospo_cmd = Server.CreateObject ("ADODB.Command")
ospo_cmd.ActiveConnection = MM_aclv4v2_STRING
ospo_cmd.CommandText = "{call dbutstandingPurchaseOrderReport(?,?,?)}"
ospo_cmd.Prepared = true
ospo_cmd.Parameters.Append ospo_cmd.CreateParameter("param1", 200, 1,
255, ospo__Location) ' adVarChar
ospo_cmd.Parameters.Append ospo_cmd.CreateParameter("param2", 135, 1,
-1, ospo__From) ' adDBTimeStamp
ospo_cmd.Parameters.Append ospo_cmd.CreateParameter("param3", 135, 1,
-1, ospo__To) ' adDBTimeStamp
Set ospo = ospo_cmd.Execute
ospo_numRows = 0
%>
When the page first loads it shows no records. I wanted to show all
records first, which is why I gave the dates presets. When I entered the
ISO date I got this error:
Application uses a value of the wrong type for the current operation.
If I manually enter the date on the page like this: 25/12/2004 then I
get the results that I expect.
What I don't understand is why the ISO dates don't work when I enter
them in to the form. Everywhere I read says I need to enter it in ISO.
The plan was to have a pop up date picker that returned the data in ISO,
but if the page won't accept ISO I will use the UK format date.
The page is for one person to use on an intranet. But I want to
understand the date in ASP and SQL, as its really doing my head in.
Thank you in advance to anyone who reads this monster post and can help me!
Steve
am building a single page report, which displays 4 columns from the
database. There are 3 filters, one is location, and the other 2 are
dates, a from and a to. When the page first loads it will show no
records, but when submitted to itself it will filter the records returned.
I am using ASP with VBScript. My database is SQL 2000 server.
I have a Stored Procedure:
ALTER PROCEDURE [dbo].[OutstandingPurchaseOrderReport]
-- Add the parameters for the stored procedure here
@Location varchar(7),
@From datetime,
@To datetime
AS
BEGIN
SELECT TOP 100 PERCENT dbo.purchaseorder.poh_order AS PONumber,
dbo.purchaseorder.poh_vendor + ' ' + dbo.vendor.vnd_name AS Vendor,
dbo.purchaseorder.poh_buyer AS Buyer,
dbo.purchaseorder.poh_orderdate AS OrderDate
FROM dbo.plannerbuyer RIGHT OUTER JOIN
dbo.purchaseorder INNER JOIN
dbo.vendor ON dbo.purchaseorder.poh_vendor =
dbo.vendor.vnd_vendor ON
dbo.plannerbuyer.plb_plannerbuyer =
dbo.purchaseorder.poh_buyer
WHERE (dbo.purchaseorder.poh_orderstatus = 'Open') AND
(dbo.plannerbuyer.plb_phonearea = CASE WHEN
@Location = 'Leeds' THEN '113' WHEN @Location = 'Wycombe' THEN '1494'
WHEN @Location = 'Both' THEN '%' END) AND
dbo.purchaseorder.poh_orderdate BETWEEN @From AND @To
ORDER BY OrderDate, PONumber
END
It takes 3 inputs from an ASP page, location, from date and to date. As
the last 2 are using datetime as the format, and the columns are
datatime, I assumed (from reading posts here) that I should be using the
ISO standard for date. Is this assumption correct?
To test my SP I did this:
EXEC OutstandingPurchaseOrderReport 'Wycombe','01/01/2001','01/01/2005'
My results:
1230002864 RAP107 Rapid Electronics Limited ANDYB 2004-02-12 00:00:00.000
1230008306 HIG1 High End Systems Inc CALLYB 2004-09-16 00:00:00.000
I also tried this EXEC OutstandingPurchaseOrderReport
'Wycombe','2004-02-12 00:00:00.000','2004-02-12 00:00:00.000'
And got exactly the same results. I am using Server Management Studio
Express, I don't know if that makes any difference.
Now on to the page itself:
<%
Dim ospo__Location
ospo__Location = "Both"
If (Request.Form("Location") <> "") Then
ospo__Location = Request.Form("Location")
End If
%>
<%
Dim ospo__From
ospo__From = "01/01/2000"
If (Request.Form("From") <> "") Then
ospo__From = Request.Form("From")
End If
%>
<%
Dim ospo__To
ospo__To = "01/01/2010"
If (Request.Form("To") <> "") Then
ospo__To = Request.Form("To")
End If
%>
<%
Dim ospo
Dim ospo_cmd
Dim ospo_numRows
Set ospo_cmd = Server.CreateObject ("ADODB.Command")
ospo_cmd.ActiveConnection = MM_aclv4v2_STRING
ospo_cmd.CommandText = "{call dbutstandingPurchaseOrderReport(?,?,?)}"
ospo_cmd.Prepared = true
ospo_cmd.Parameters.Append ospo_cmd.CreateParameter("param1", 200, 1,
255, ospo__Location) ' adVarChar
ospo_cmd.Parameters.Append ospo_cmd.CreateParameter("param2", 135, 1,
-1, ospo__From) ' adDBTimeStamp
ospo_cmd.Parameters.Append ospo_cmd.CreateParameter("param3", 135, 1,
-1, ospo__To) ' adDBTimeStamp
Set ospo = ospo_cmd.Execute
ospo_numRows = 0
%>
When the page first loads it shows no records. I wanted to show all
records first, which is why I gave the dates presets. When I entered the
ISO date I got this error:
Application uses a value of the wrong type for the current operation.
If I manually enter the date on the page like this: 25/12/2004 then I
get the results that I expect.
What I don't understand is why the ISO dates don't work when I enter
them in to the form. Everywhere I read says I need to enter it in ISO.
The plan was to have a pop up date picker that returned the data in ISO,
but if the page won't accept ISO I will use the UK format date.
The page is for one person to use on an intranet. But I want to
understand the date in ASP and SQL, as its really doing my head in.
Thank you in advance to anyone who reads this monster post and can help me!
Steve