I have below Function:

```
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

```

When I try cast nvarchar to bigint when calling this function it gives me error:

```
select dbo.ToDotNetDateTime(CAST(UTC_Time AS BIGINT)) FROM OtoSuite_Master_Reply

```

Error says: **Error converting data type nvarchar to bigint**