title: SQL date parameter
body: <p>I am trying to convert bigint column to a date, and I then need to use this date as 2 parameters in SQL. I need to use a startdate off 20200101 and the end date needs to be today, like a getdate().</p>
  <p>This is coming up with an error and I can't find out how to do it.</p>
  <pre><code>set @date1 TRY_CAST(CAST(CAST([DischargeDateKey] AS BIGINT) AS VARCHAR(8)) AS DATETIME)
  set @date2 TRY_CAST(CAST(CAST([DischargeDateKey] AS BIGINT) AS VARCHAR(8)) AS DATETIME)
  
  DECLARE @date1 AS datetime = 20200101
  DECLARE @date2 AS datetime  = 20220531
  </code></pre>
  <blockquote>
  <p>Msg 102, Level 15, State 1, Line 3 Incorrect syntax near 'TRY_CAST'.</p>
  </blockquote>
  <p>Please someone please help?</p>