title: Pass Interval parameter to Function in SQL
body: <p>I want to create a function which returns a temporary table of dates, for report generation. I want to be able to specify the interval for the table dynamically. Below is a function that encapsulates my problem.</p>
  
  <p>Consider:</p>
  
  <pre><code>CREATE FUNCTION [dbo].[DateAdder]
  (@DateStart datetime,
  @increment int,
  @interval ?????)
  Returns datetime
  AS
  BEGIN
  Declare @Return datetime
  SELECT @Return = DATEADD(@interval, @increment, @DateStart)
  return @Return
  END
  </code></pre>
  
  <p>Is there a way to pass the "Interval" into this function?</p>
  
  <p>(Obviously, I am not trying to rewrite the <code>DATEADD</code> function, I am just using this as an example to highlight my issue).</p>
  
  <p>Cheers!</p>