title: Google Script - Function - Not Defined
body: <p>I have the following script that is used to apportion each month as 1/12th of the year and find the difference between 2 dates. For example the function sums January to June as 50% of the year instead of 49% (181/365). I would like to move my excel s/s to Google but can't seem to get the function working in Google Script.</p>
  
  <p><strong>Excel Script</strong></p>
  
  <pre><code>Function PartMonths(x, y)
  
  PartMonths = (DateDiff("M", (DateSerial(Year(x), Month(x) + 1, 1) - 1), 
  (DateSerial(Year(y), Month(y) + 1, 1) - 1) + 1) - 2 + Day(y) / 
  Day(DateSerial(Year(y), Month(y) + 1, 1) - 1) + (Day(DateSerial(Year(x), 
  Month(x) + 1, 1) - 1) - Day(x) + 1) / Day(DateSerial(Year(x), Month(x) + 1, 
  1) - 1)) / 12
  
  End Function
  </code></pre>
  
  <p><strong>Google Script</strong></p>
  
  <pre><code>function PartMonths(x, y) 
  
  { return PartMonths =(DateDif((Date(Year(x), Month(x) + 1, 1)), 
  (Date(Year(y), Month(y) + 1, 1) - 1) + 1,"M") - 1 + Day(y) / 
   Day(Date(Year(y), Month(y) + 1, 1) - 1) + (Day(Date(Year(x), Month(x) + 1,
   1) - 1) - Day(x) + 1) / Day(Date(Year(x), Month(x) + 1, 1)-1))
   }
  </code></pre>
  
  <p>x and y are dates which are variable inputs. When debugging the code in Google Scripts it says 'ReferenceError: "DateDif" is not defined'</p>
  
  <p>I'm not sure how to define it? Help!</p>