• There are a few things that would make this easier to help with:

    1. Execution plans for each query

    2. The code for dbo.fn_cti_convertardatetime

    3. The schema for the tables used. Especially indexes on the tables.

    Off the top of my head I can tell you that the last one runs so long because the use of the scalar function to get LastResolvedDate. Because it is used in derived table and then that derived column is being used in the Where clause the query is essentially turned into a cursor because it has to process the entire result set to get the date in human readable format and then compare each row to the data value supplied. The best it can do is an index or table scan, there is no possibility of a seek.

    You are much better off using the base column in the WHERE clause and then applying a function to the passed in date to convert it to the format stored in the base column. You can still use the function in the SELECT clause to return the date in human readable format, but don't use that in the WHERE clause.