Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RemoveBackwardsCompatibility/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/FormulaParsing/Excel/Functions/DateTime/Edate.cs

Last change on this file was 12074, checked in by sraggl, 10 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 781 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using OfficeOpenXml.FormulaParsing.ExpressionGraph;
6
7namespace OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime
8{
9    public class Edate : ExcelFunction
10    {
11        public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
12        {
13            ValidateArguments(arguments, 2, eErrorType.Value);
14            var dateSerial = ArgToDecimal(arguments, 0);
15            var date = System.DateTime.FromOADate(dateSerial);
16            var nMonthsToAdd = ArgToInt(arguments, 1);
17            var resultDate = date.AddMonths(nMonthsToAdd);
18            return CreateResult(resultDate.ToOADate(), DataType.Date);
19        }
20    }
21}
Note: See TracBrowser for help on using the repository browser.