title: How to use timestamp as parameter
body: <p>I have a simple query I use frequently to get all weightdata on a certain production line between a specific time period. </p>
  
  <p>Now I want to convert the query I have to a visual studio report so other people can run the report instead of asking me. </p>
  
  <p>As a first step I'm trying to run a query in management studio to see if it works. </p>
  
  <pre><code>DECLARE @ProductionLineID as int
  Set @ProductionLineID = 11
  DECLARE @Start as timestamp
  Set @Start = '2018-06-29 19:20'
  DECLARE @End as timestamp
  Set @End = '2018-06-30 19:10' 
  
  SELECT [ProductionLineId]
        ,[Timestamp]
        ,[ActiveRecipe]
        ,[ActualWeight]
        ,[SetWeight]
        ,[SetBoxWeight]
        ,[SetMaxTolerance]
        ,[SetMinTolerance]
        ,[DeviationFromSetWeight]
        ,[AmountOfProductInBox]
        ,[AverageProductWeightPerBox]
        ,[ActualSealTemp]
        ,[ActualCuttingTemp]
        ,[ParametersChanged]
        ,[rejectError]
    FROM [PP_Staging].[NIV].[Packaging]
  
    where ProductionLineId = @ProductionLineID
    and timestamp between @Start and @End
  
    order by Timestamp
  </code></pre>
  
  <p>This results in the following error</p>
  
  <pre><code>Msg 257, Level 16, State 3, Line 5
  Implicit conversion from data type varchar to timestamp is not allowed. Use the CONVERT function to run this query.
  Msg 257, Level 16, State 3, Line 7
  Implicit conversion from data type varchar to timestamp is not allowed. Use the CONVERT function to run this query.
  </code></pre>
  
  <p>So I tried the convert function on the relevant part:</p>
  
  <pre><code>DECLARE @Start as timestamp
  Set @Start = convert(timestamp, '2018-06-29 19:20')
  DECLARE @End as timestamp
  Set @End = convert(timestamp, '2018-06-30 19:10')
  </code></pre>
  
  <p>Which results in </p>
  
  <pre><code>Msg 8115, Level 16, State 2, Line 9
  Arithmetic overflow error converting expression to data type datetime.
  </code></pre>
  
  <p>So first question would be how do I input/set this parameter so I can test the report?</p>
  
  <p>I know my code works if I enter it manually, so I'm basically searching for a way of converting this manual query into a report with variables. Once I have that I can try to figure out how to setup the report.</p>
  
  <p>Working code sample:</p>
  
  <pre><code>SELECT [ProductionLineId]
        ,[Timestamp]
        ,[ActiveRecipe]
        ,[ActualWeight]
        ,[SetWeight]
        ,[SetBoxWeight]
        ,[SetMaxTolerance]
        ,[SetMinTolerance]
        ,[DeviationFromSetWeight]
        ,[AmountOfProductInBox]
        ,[AverageProductWeightPerBox]
        ,[ActualSealTemp]
        ,[ActualCuttingTemp]
        ,[ParametersChanged]
        ,[rejectError]
    FROM [PP_Staging].[NIV].[Packaging]
  
    where ProductionLineId = 11
    and timestamp between '2018-06-29 19:20' and '2018-06-30 19:10'
  
    order by Timestamp
  </code></pre>