title: SQL CLR and nullable datetime parameter
body: <p>I'm trying to write a SQLCLR function that takes a DateTime2 as input and returns another DateTime2. Based on this <a href="https://stackoverflow.com/questions/2620524/sqlclr-and-datetime2">post</a> I altered the parameter to be the C# type DateTime giving me the level of precision I require.  However because the input can be null I would like it to be DateTime?; the return type as well.</p>
  
  <pre><code>using System;
  using Microsoft.SqlServer.Server;
  
  namespace SqlServer.Functions {
      public class UserDefinedFunctions {
          [SqlFunction(DataAccess = DataAccessKind.None)]
          public static DateTime? GetLocalTimeFromGMT(DateTime? dateTime) {
              if (dateTime.HasValue)
                  return DateTime.SpecifyKind(dateTime.Value, DateTimeKind.Utc).ToLocalTime();
              else
                  return (DateTime?)null;
          }
      }
  }
  </code></pre>
  
  <p>The problem is I get the following error when I try to deploy:</p>
  
  <blockquote>
    <p>Error 1   Cannot find the type 'Nullable`1', because it does not exist or you do not have permission. SqlServer.Functions</p>
  </blockquote>
  
  <p>I'm using Sql Server 2008 and Visual Studio 2008.</p>