Conversion failed when converting date in stored procedure
I have store procedure like this: ALTER procedure [dbo].[ParkingSummary1]
@startdate varchar(100), @enddate varchar(100) as begin declare @date1
datetime = CONVERT(datetime, @startdate + ' 00:01:00.000', 120); declare
@date2 datetime = CONVERT(datetime, @enddate + ' 23:23:59.000', 120);
DECLARE @cols AS NVARCHAR(MAX), @query AS NVARCHAR(MAX) select @cols =
STUFF((SELECT distinct ',' + QUOTENAME(Vtype) from VType_tbl FOR XML
PATH(''), TYPE ).value('.', 'NVARCHAR(MAX)') ,1,1,'') set @query = 'SELECT
LocName, ' + @cols + ' from ( select l.LocName,Vtype from Transaction_tbl
t join VType_tbl v on t.vtid = v.vtid join dbo.Location_tbl l on
t.locid=l.Locid where dtime between '''+ @date1+''' and '''+@date2+''' and
Status = 5 ) d pivot ( count(Vtype) for Vtype in (' + @cols + ') ) p '
exec sys.sp_executesql @query end.while am passing startand enddate like
this: @startdate = '2013-08-05', @enddate = '2013-08-08' am getting error
like this:Conversion failed when converting date and/or time from
character string.
No comments:
Post a Comment