title: Create a function which will return 4 output columns
body: <p>Create table holiday master which will have column name as holiday date,day (Sunday,monday or any public holiday holiday).</p>
  
  <p>Create a function which will return 4 output columns: Date, Day of month, year &amp; day.
  Date will be working dates between 2 dates (Ignore dates present in holiday master table)</p>
  
  <pre><code>CREATE function DATENEWww
  AS 
  BEGIN
  DECLARE @StartDate DATETIME
  DECLARE @MIDDLEDATE DATETIME
  DECLARE @EndDate DATETIME
  SET @StartDate = '2013/05/01'
  SET @EndDate = '2013/05/10'
  
  SELECT getday()'Day', getDATE() 'Today', YEAR(GETDATE()) 'YEAR Part'
  SELECT 
     (DATEDIFF(dd, @StartDate, @EndDate) + 1)
    -(DATEDIFF(wk, @StartDate, @EndDate) * 2)
    -(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END)
    -(CASE WHEN DATENAME(dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END)
    -(CASE WHEN DATENAME (DW, @MIDDLEDATE)='SELECT HOLIDAY_DATE FROM HOLIDAY_MASTER' THEN 1 ELSE 0 END)
  
    END
  </code></pre>