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
close icon

Essential Calculate (CalcQuick) question: YEAR(TODAY()) not working?

Hello,

we use CalcQuick to calculate some formula. The below test code uses the YEAR(TODAY()) to get the year of today. But it receives #value error. Can you give example how to use it correctly?


var calculator = new CalcQuick();
calculator.setAutoCalc(false);
calculator.setKeyValue("__formula", "=YEAR(TODAY())");
calculator.refreshAllCalculations();
var val = calculator.getKeyValue("__formula");
console.log(val); 
=> result is #VALUE! error

Thanks!
Hui

3 Replies

PM Piruthiviraj Malaimelraj Syncfusion Team August 25, 2017 05:32 PM UTC

Hi Hui, 

Thanks for your interest in Syncfusion products, 

We have analyzed your scenario and able to reproduce the scenario at our end. In order to resolve the reported issue, enable ExcelLikeComputations value of CalcEngine. Please make use of the below code and refer to the attached sample, 

Code snippet: 
var calculator = new CalcQuick(); 
calculator.getEngine().setExcelLikeComputations(true); 
calculator.setAutoCalc(false); 
 
calculator.setKeyValue("A", "=YEAR(TODAY())"); 
calculator.refreshAllCalculations(); 
var val = calculator.getKeyValue("A"); 

Sample link: 

Regards, 
Piruthiviraj 



HZ hui zheng August 28, 2017 07:44 AM UTC

Hi,

Yes, after ExcelLikeComputations is enabled, it works.

Thanks!

Hui



MG Mohanraj Gunasekaran Syncfusion Team August 29, 2017 04:17 AM UTC

Hi Hui,  
 
Thanks for your update. 
 
We are glad to know that your reported problem has resolved. 
 
Please let us know if you have any further assistance. 
 
Regards, 
Mohanraj G 


Loader.
Live Chat Icon For mobile
Up arrow icon