What exactly do you mean 'translate' this to Tableau? Do you intend to connect to this stored procedure directly exactly as it is? Or are you trying to connect to the individual tables in the connection window then impose filters in Tableau to replicate the stored proc? Or take the SQL out of the stored procedure and put it into a 'custom sql' within Tableau?
I would like to use this SQL query in tableau. This query works in MS SQL Server 2008. But when I connecting to MS SQL Server and use the query in tableau, request does not work. There is parameters Parameters.Date1 and Parameters.Date2 on my worksheet in tableau. I would like to use Parameters.Date1 and Parameters.Date2 instead of @time. How should I change SQL query in order to it works in tableau?
Take a look at the help page on custom sql, there is a specific section on using parameters.
You will need to remove the DECLARE @time from your SQL and only have the select in the custom sql dialog.
You then need to replace each instance of @time in your SQL to use the parameters you've created. That should be pretty straight forward in the where clause, it should look something like WHERE Start >= <parameters.date1> and Start <= <Parameters.Date2>
I don't know how you would change this reference though; cast(DATEADD(SECOND, sum(datediff(DAY, @time,[Start])),@time) as date)'Date'
Your procedure right now relies on ONE date field so this works fine. However if you move to an approach with two date parameters, I don't know which you would use here. It feels like you should probably use the [Time] field in the datasource, but I don't know enough about your schema or data to advise.