title: SQL Convert datatype of input parameter inside Function call
body: <p>I have below Function:</p>
  <pre><code>CREATE FUNCTION dbo.ToDotNetDateTime ( @Ticks bigint )
      RETURNS datetime2
  AS
  BEGIN
      DECLARE @DateTime datetime2 = '00010101';
      SET @DateTime = DATEADD( DAY, @Ticks / 864000000000, @DateTime );
      SET @DateTime = DATEADD( SECOND, ( @Ticks % 864000000000) / 10000000, @DateTime );
      RETURN DATEADD( NANOSECOND, ( @Ticks % 10000000 ) * 100, @DateTime );
  END
  </code></pre>
  <p>When I try cast nvarchar to bigint when calling this function it gives me error:</p>
  <pre><code>select dbo.ToDotNetDateTime(CAST(UTC_Time AS BIGINT)) FROM OtoSuite_Master_Reply
  </code></pre>
  <p>Error says: <strong>Error converting data type nvarchar to bigint</strong></p>