title: Using Date.Now in SQL Function
body: <p>I have a <code>Function</code> like this;</p>
  
  <pre><code>ALTER FUNCTION [dbo].[fngcodeme]
  (
      @HESAP INT, @DOV INT, @TEKLIF VARCHAR(10), @BAS datetime, @BIT datetime
  )
  RETURNS FLOAT
  
  AS
  BEGIN
  
  DECLARE @Result FLOAT
  
  IF CONVERT(DATETIME, @BIT,103) &lt;= '20110228'
      SET @Result = (SELECT SUM(TUTAR)
          FROM YAZ..MARDATA.M_HAREKET
          WHERE TEMEL_HESAP = @HESAP
          AND DOVIZ_KOD = @DOV
          AND REF_KOD = 'GC'
          AND BACAK_GRUP = 'PERT'
          AND ISL_KOD = 1
          AND ACIKLAMA LIKE '%' + @TEKLIF + '%'
          AND ISL_TAR &gt;= CONVERT(DATETIME, @BAS,103)
          AND ISL_TAR &lt;= CONVERT(DATETIME, @BIT,103)
          )
  ELSE
      SET @Result = (SELECT SUM(TUTAR)
          FROM YAZ..MARDATA.M_GHAREKET
          WHERE TEMEL_HESAP = @HESAP
          AND DOVIZ_KOD = @DOV
          AND REF_KOD = 'GC'
          AND BACAK_GRUP = 'PERT'
          AND ISL_KOD = 1
          AND ACIKLAMA LIKE '%' + @TEKLIF + '%'
          AND ISL_TAR &gt;= CONVERT(DATETIME, @BAS,103)
          AND ISL_TAR &lt;= CONVERT(DATETIME, @BIT,103)
          )
  
  RETURN @Result
  
  END
  </code></pre>
  
  <p><code>M_GHAREKET</code> table is my monthly data table. Every end of the month this table load to <code>M_HAREKET</code>. (And deleted all data in <code>M_GHAREKET</code>)</p>
  
  <p><code>M_HAREKET</code> is a Big Bucket. <code>M_GHAREKET</code> is small. (I mean <code>M_HAREKET</code> has now over 500.000 data, <code>M_GHAREKET</code> over 4.000)</p>
  
  <p>What i want is for this <code>Function</code>, IF @BAS date's month value is equal <code>DateTime.Now.Month</code> value i want use <code>M_GHAREKET</code> table, else use <code>M_HAREKET</code> table.</p>
  
  <p>How should i change this function like that?</p>
  
  <p>Is it possible like this IF clause with <code>DateTime.Now.Month</code> in <code>SQL Function</code>?</p>
  
  <p>Or i should use in my <code>ASP.NET</code> page? How can i do that?</p>