On the creation of a new entry on this table the following error is produced."Conversion failed when converting datetime from character string"USE [PUniTest]GO/****** Object: Trigger [dbo].[SUMMARY_UPDATE_Profile] Script Date: 09/07/2010 09:46:43 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- =============================================CREATE TRIGGER [dbo].[SUMMARY_UPDATE_Profile] ON [dbo].[Profile]FOR INSERT, UPDATEASDeclare @Custid Varchar(50)Declare @Year varchar(4)Declare @Month varchar(2)Select @Custid=CustidFROM inserted WHEREisnull(inserted.repyear,'') > ''ANDisnull(inserted.repmonth,'') > ''IF @Custid IS NOT NULL and TRIGGER_NESTLEVEL() > 1 RETURNBeginSelect @Year = RepYearfrom insertedwhere Custid = @CustidSelect @Month = RepMonthfrom insertedwhere Custid = @CustidUPDATE Profileset profile.RepNumExtAccess = t1.RepNumExtAccess,profile.RepNumJanetAccess = t2.RepNumJanetAccess,profile.RepNumJanetService = t3.RepNumJanetService,profile.AvgDurExtAccess = t1.AvgDurExtAccess,profile.AvgDurJanetAccess = t2.AvgDurJanetAccess,profile.AvgDurJanetService = t3.AvgDurJanetService,profile.MaxDurExtAccess = t1.MaxDurExtAccess,profile.MaxDurJanetAccess = t2.MaxDurJanetAccess,profile.MaxDurJanetService = t3.MaxDurJanetService,profile.OversixtyExtAccess = t1.OversixtyExtAccess,profile.OversixtyJanetAccess = t2.OversixtyJanetAccess,profile.OversixtyJanetService = t3.OversixtyJanetServicefrom profile, (Select Count(Callid) as "RepNumExtAccess" , Avg(RepDuration) as "AvgDurExtAccess",Max(RepDuration) as "MaxDurExtAccess",(Select COUNT (callid) from calllog where calllog.repduration > 60 and calllog.swerncode = 'Ext-access' andMonth (cast(IncidentStart as datetime)) = datepart(month,(cast('2018-'+@month+'-20' as datetime)))ANDYear(cast(IncidentStart as datetime)) = datepart(year,(cast(@year+'-01'+'-20' as datetime)))) as "OversixtyExtAccess"from calllogwhere calllog.swerncode = 'Ext-access' andMonth (cast(IncidentStart as datetime)) = datepart(month,(cast('2018-'+@month+'-20' as datetime)))ANDYear(cast(IncidentStart as datetime)) = datepart(year,(cast(@year+'-01'+'-20' as datetime)))) as "t1",(Select Count(Callid) as "RepNumJanetAccess" , Avg(RepDuration) as "AvgDurJanetAccess",Max(RepDuration) as "MaxDurJanetAccess",(Select COUNT (callid) from calllog where calllog.repduration > 60 and calllog.swerncode = 'Janet-access' andMonth (cast(IncidentStart as datetime)) = datepart(month,(cast('2018-'+@month+'-20' as datetime)))ANDYear(cast(IncidentStart as datetime)) = datepart(year,(cast(@year+'-01'+'-20' as datetime)))) as "OversixtyJanetAccess"from calllogwhere calllog.swerncode = 'Janet-access' andMonth (cast(IncidentStart as datetime)) = datepart(month,(cast('2018-'+@month+'-20' as datetime)))ANDYear(cast(IncidentStart as datetime)) = datepart(year,(cast(@year+'-01'+'-20' as datetime)))) as "t2",(Select Count(Callid) as "RepNumJanetService" , Avg(RepDuration) as "AvgDurJanetService",Max(RepDuration) as "MaxDurJanetService",(Select COUNT (callid) from calllog where calllog.repduration > 60 and calllog.swerncode = 'Janet-service' andMonth (cast(IncidentStart as datetime)) = datepart(month,(cast('2018-'+@month+'-20' as datetime)))ANDYear(cast(IncidentStart as datetime)) = datepart(year,(cast(@year+'-01'+'-20' as datetime)))) as "OversixtyJanetService"from calllogwhere calllog.swerncode = 'Janet-service' andMonth (cast(IncidentStart as datetime)) = datepart(month,(cast('2018-'+@month+'-20' as datetime)))ANDYear(cast(IncidentStart as datetime)) = datepart(year,(cast(@year+'-01'+'-20' as datetime)))) as "t3"Where Profile.CustiD = @CustidEND