title: How to insert current date into subject line of email SQL Server
body: <p>I have a stored procedure which generates a certain table which I need to email my email list with a specific subject line with the current date. I used the GETDATE() function but I'm getting an error. Below is my code:<br/></p>
  
  <pre><code>    if exists (select * from #Notify)
      begin
  
          declare
              @TableHtml varchar(max);
  
          exec GetTableHtml #Notify, @TableHtml = @TableHtml output;
  
              declare
                  @FromName varchar(128) = 'AB',
                  @FromEmail varchar(128) = 'ab@xy.com',
                  @ToEmailListName varchar(max) = 'SomeList',
                  @SubjectTxt varchar(max) = 'Some text' + cast(GETDATE() as date),
                  @BodyTxt varchar(max) = 'Body content:&lt;br&gt;&lt;br&gt;' + @TableHtml + '
                  &lt;br&gt;&lt;br&gt;Thanks.';
  
              exec StartSendEmail
                  @FromName = @FromName,
                  @FromEmail = @FromEmail,
                  @ToEmailListName = @ToEmailListName,
                  @SubjectTxt = @SubjectTxt,
                  @BodyTxt = @BodyTxt;
  
      end
  </code></pre>
  
  <p>The error I'm getting:<br/><a href="https://i.stack.imgur.com/3nyVi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3nyVi.png" alt="enter image description here"></a></p>