-
Passing Dates into Stored Procedures
For some reason, the Query works fine in a webform but not in a stored procedure.
When I pass a date into the stored procedure, I get a cast error.
[Microsoft][ODBC SQL Server Driver] Invalid Character value for cast specification.
Any help would be greatly appreciated!
Working SQL Query
-----------------
SELECT *
FROM dbo.main_ca
WHERE (date_submit >= 'MMdatefrom') AND (date_submit < 'MMdateto')
ORDER BY id_stamp DESC
Not Working SP
--------------
CREATE PROCEDURE sp_daterange
@datefrom datetime,
@dateto datetime
AS
SELECT *
FROM main_ca
WHERE (date_submit >= '@datefrom') AND (date_submit < '@dateto')
ORDER BY id_stamp DESC
GO
date_submit is data type of datetime
Thank you in advance!
-
--try this
CREATE PROCEDURE sp_daterange
@datefrom datetime,
@dateto datetime
AS
SELECT *
FROM main_ca
WHERE (date_submit >= @datefrom) AND (date_submit < @dateto)
ORDER BY id_stamp DESC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|