• My apologies.
    I’m using a scalar function to return SLAHours, in my stored procedure (below). I have identified a need to convert those hours back to seconds in my report, so that I can insert an indicator (of exceeds SLA threshold) using seconds in my range. The formula that I’m getting the error for is the convert SLAHours back to seconds.

    The SLA hours is set to accept hours exceeding 99, in case the agent is not closing requests quickly. Example: Some rows my only have HH:MM:SS while other rows may show HHH:MM:SS.
    I was trying to use the length of the data within the field LEN() to set a condition by which to apply the formula. This is my formula, which is not working properly.

    SELECT req.[ID]
           ,req.[RequestTypeId]
           ,reqt.[RequestType]
           ,req.[RequestStatusId]
    ,reqs.[RequestStatus]
           ,req.[DateSubmitted] as RequestDate
           ,DATENAME(dw,req.DateSubmitted) as RequestDateName
           ,req.[Department]
           ,req.[LeadId]
           ,req.[PropertyCode]
           ,Prpty.Property
           ,Prpty.Location
           ,req.[TourSite]
           ,Office.[Location] as TourLocation
           ,req.[DateClosed] as FinalStatusDate
           ,DATENAME(dw,req.DateClosed) as FinalStatusDateName
    ,[I3_CMS].[dbo].[fnFullfillmentSLAHoursCalc](req.DateSubmitted, ISNULL(req.[DateClosed],'1/1/1900')) as SLAHours
           ,req.[ClosedBy] as ClosingAgentMSLogin
           ,users.TSR as ClosingAgentTSR
      FROM [HUB].[RMS].[Requests] req
      left join [HUB].[RMS].[RequestType] reqt ON req.[RequestTypeId] = reqt.[RequestTypeId]
      left join [HUB].[RMS].[RequestStatus] reqs ON req.[RequestStatusId] =     reqs.[RequestStatusId]
      left Join [HUB].[dbo].[aspnet_Users] users ON  req.[ClosedBy]= users.[UserName]
      left Join [HUB].[RMS].[PropertyLocation] Prpty ON req.[PropertyCode] =  Prpty.[PropertyCode]
      left join [HUB].[RMS].[Offices] Office ON req.TourSite = Office.[Office]
      Where [DateSubmitted] >= @StartDateTime and [DateSubmitted] <= @EndDateTime AND
      REQ.[RequestTypeId] in ('1','2','3') 
      Order by LeadID