title: Convert SQL query to SQL functions?
body: <p>I'm working on SQL functions</p>
  
  <p>I create a query and query successful run but I wan to convert them SQL functions</p>
  
  <p>I'm returning two parameter in query days and years</p>
  
  <p>I want to convert SQL query to SQL function see below image</p>
  
  <p><a href="https://i.stack.imgur.com/kdVUB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kdVUB.png" alt="enter image description here"></a></p>
  
  <p>sql query</p>
  
  <pre><code>    Declare @dateofbirth datetime  
      Declare @currentdatetime datetime  
      Declare @years varchar(4)  
      Declare @days varchar(4)  
      set @dateofbirth = '2020-01-25 ' 
      set @currentdatetime  = getdate()   
      select @years = datediff(year,@dateofbirth,@currentdatetime)    
      select @days = datediff(DAY,@dateofbirth,@currentdatetime)
      select @years   + ' years,'  
      select @days   + ' days,'
  </code></pre>
  
  <p><strong>can I use Multi-statement table-valued functions (MSTVF) because my query return multiple parameter days and years</strong>?</p>
  
  <p>3 function available in ssms</p>
  
  <ul>
  <li><p>table-valued functions  </p>
  
  <ul>
  <li>new inline table valued function</li>
  <li>scalar multi statement table valued function </li>
  </ul></li>
  <li><p>scalar-valued functions</p></li>
  <li>aggregate functions</li>
  </ul>
  
  <p>I am not sure which function should be use?</p>
  
  <p>I want to convert SQL query to SQL function?</p>