We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

user defined function arguments

Hi, I created a new function to finf difference between two dates. and added to the syncfusion .The argument values are get changed if I enter date (like 03/03/2005 or 12/9/2004 2:42:00 AM)for argumet value. I need to get same values when read from arguments. Below is my function public string ComputeDays360(string argList) { GridFormulaCellModel model = this.gridControl.CellModels["FormulaCell"] as GridFormulaCellModel; string[] args = argList.Split(new char[]{'',''}); int argCount = args.GetLength(0); if(argCount != 2 && argCount != 3) { return "wrong number of arguments"; } double serialdate1; double serialdate2; bool method = false; int days = 0; string arg1 = args[0]; string arg2 = args[1]; if(double.TryParse(model.Engine.GetValueFromArg(args[0]), NumberStyles.Any, null, out serialdate1) && double.TryParse(model.Engine.GetValueFromArg(args[1]), NumberStyles.Any, null, out serialdate2) && (argCount == 2 || (method = (args[2] == "TRUE"))) ) { DateTime dt1 = DateTime.FromOADate((int)serialdate1); DateTime dt2 = DateTime.FromOADate((int)serialdate2); bool flipSign = false; if(dt1.Day == 31) dt1 = dt1.AddDays(-1); if(dt2.Day == 31 && !method && dt1.Day < 30) dt2 = dt2.AddDays(1); else if (dt2.Day == 31) dt2 = dt2.AddDays(-1); if(dt2 < dt1) { flipSign = true; DateTime t = dt1; dt1 = dt2; dt2 = t; } days = dt2.Day - dt1.Day; days += 30 * (dt2.Month - dt1.Month); days += 360 * (dt2.Year - dt1.Year); if(flipSign) days = -days; } else return "Invalid Arguments"; return days.ToString(); } In the above function args[0],args[1] values are get changed if I pass the value like 03/02/2005. Pls advice me what are the changes I need to do? MALLIK

1 Reply

AD Administrator Syncfusion Team March 31, 2005 08:47 AM UTC

I do not understand your question. Are you saying that when you type =DAYS360(DATEVALUE("3/3/2005"),TODAY()) in a cell, and then move off the cell, and back onto the cell, the same string is not present in the cel at that point? Or are you saying, you want to type something like =DAYS360(3/3/2005,4/4/2005) and have it compute things from there. Or do you want something else?

Live Chat Icon For mobile
Up arrow icon