I have this stored Proc:
ALTER Procedure [dbo].[GetWebinars]
(
@GroupingCode varchar(max) = 'AVM',
@ItemNumber varchar(max) out,
@Title varchar(max) out,
@SubTitle varchar(max) out,
@ShortDescription varchar(max) out,
@LongDescription varchar(max) out,
@ShortImageUrl varchar(max) out,
@MedImageUrl varchar(max) out,
@LgImageUrl varchar(max) out,
@GroupCode varchar(max) out,
@StartDate varchar(max) out
)
AS
select
@GroupingCode = prdtemp.groupingcode,
@ItemNumber = prd.itemnumber,
@Title = t.brochuredesc,
@SubTitle = prdtemp.SubTitle,
@ShortDescription = prdtemp.shortdescription,
@LongDescription = prdtemp.longdescription,
@ShortImageUrl = prdtemp.SmallImagePath,
@MedImageUrl = prdtemp.MediumImagePath,
@LgImageUrl = prdtemp.LargeImagePath,
@GroupCode = prd.GroupCode,
@StartDate = s.StartDate
from pryor_producttemplate prdtemp
inner join pryor_prdItmmst prd
on prdtemp.groupingcode = prd.groupcode
inner join pryor_topics t
on prd.itemnumber = t.topiccode
inner join Pryor_Schedule s
on t.TopicCode = s.topiccode
where prdtemp.groupingcode=@GroupingCode and t.country = 'U.S.A'
My issue is @StartDate is a var char in the DB. How can I convert this to a proper date to render as D/M/YY?
You use the
convertfunction to convert the string to a datetime:The third parameter specifies the date format. The value 120 for example specifies the human friendly ISO 8601 format. See the reference for CAST and CONVERT for all date formats supported.
Naturally you also have to change the type of the variable: