Difference between revisions of "YearFrac"

 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Date and Time Functions]]
 
[[Category:Date and Time Functions]]
''New to [[What's new in Analytica 4.2?|Analytica 4.2]]''
+
[[Category:Financial Functions]]
  
= YearFrac(startDate,endDate'',basis'') =
+
== YearFrac(startDate, endDate'', basis'') ==
  
Calculates the fractional number of years elapsed between startDate and endDate, based on various artificial year standards that are sometimes used with financial instruments and obligations.  The result is always positive, with the result being the span between the lesser of the two dates and the greater of the two dates.
+
Calculates the fractional number of years elapsed between «startDate» and «endDate», based on various artificial year standards that are sometimes used with financial instruments and obligations.  The result is always positive, with the result being the span between the lesser of the two dates and the greater of the two dates.
  
The basis specifies the method used to measure the fractional portion of the year.  The possible values for basis are as follows:
+
The «basis» parameter specifies the method used to measure the fractional portion of the year.  The possible values for «basis» are as follows:
* 0 (or omitted) = US (NASD) 30/360
+
:<code>0</code> (or omitted) = US (NASD) 30/360
* 1 = actual/actual
+
:<code>1</code> = actual/actual
* 2 = Actual/360
+
:<code>2</code> = Actual/360
* 3 = Actual/365
+
:<code>3</code> = Actual/365
* 4 = European 30/360
+
:<code>4</code> = European 30/360
  
 
The function is implemented to match the results computed by Excel 2003 for dates after 1900.   
 
The function is implemented to match the results computed by Excel 2003 for dates after 1900.   
  
«startDate» and «endDate» are numeric, representing the number of days elapsed since the date origin. If these are fractional (e.g., with a time component), they are truncated to an integer date.  You can use the function [[MakeDate]] to create a date within an expression, or you can enter a single date into a definition or table cell when the number format for that variable is set to date.
+
«startDate» and «endDate» are numeric, representing the number of days elapsed since the date origin. If these are fractional (e.g., with a time component), they are truncated to an integer date.  You can use the function [[MakeDate]] to create a date within an expression, or you can enter a single date into a definition or table cell when the number format for that variable is set to date.
 
 
= Notes =
 
  
 +
== Notes ==
 
For date ranges that do not span the date 29-Feb-1900 [sic], the results returned by Analytica's [[YearFrac]] match those of Excel.  Analytica does not duplicate Excel's 29-Feb-1900 bug (Excel treats 1900 as a leap year, even though it was not).
 
For date ranges that do not span the date 29-Feb-1900 [sic], the results returned by Analytica's [[YearFrac]] match those of Excel.  Analytica does not duplicate Excel's 29-Feb-1900 bug (Excel treats 1900 as a leap year, even though it was not).
  
= See Also =
+
==History==
 +
[[YearFrac]] was introduced in [[Analytica 4.2]].
  
 +
== See Also ==
 +
* [[ParseDate]]
 +
* [[MakeDate]]
 +
* [[Special Handling of Date Values]]
 
* [[Date Functions]]
 
* [[Date Functions]]
 +
* [[Financial functions]]

Latest revision as of 00:46, 2 February 2016


YearFrac(startDate, endDate, basis)

Calculates the fractional number of years elapsed between «startDate» and «endDate», based on various artificial year standards that are sometimes used with financial instruments and obligations. The result is always positive, with the result being the span between the lesser of the two dates and the greater of the two dates.

The «basis» parameter specifies the method used to measure the fractional portion of the year. The possible values for «basis» are as follows:

0 (or omitted) = US (NASD) 30/360
1 = actual/actual
2 = Actual/360
3 = Actual/365
4 = European 30/360

The function is implemented to match the results computed by Excel 2003 for dates after 1900.

«startDate» and «endDate» are numeric, representing the number of days elapsed since the date origin. If these are fractional (e.g., with a time component), they are truncated to an integer date. You can use the function MakeDate to create a date within an expression, or you can enter a single date into a definition or table cell when the number format for that variable is set to date.

Notes

For date ranges that do not span the date 29-Feb-1900 [sic], the results returned by Analytica's YearFrac match those of Excel. Analytica does not duplicate Excel's 29-Feb-1900 bug (Excel treats 1900 as a leap year, even though it was not).

History

YearFrac was introduced in Analytica 4.2.

See Also

Comments


You are not allowed to post comments.