I need to get date from a cell but function GetValue() keeps returning data in standart format.
example: 06.12.2023 but it returns 45266
Basicaly I need to get it and put in a Date variable.
What can I do in this situation? Should I use other function or is it api issue?
You have to additionally set number format for the cell with method SetNumberFormat.
Here is a small example:
var oSheet = Api.GetActiveSheet();
var dataValue = oSheet.GetRange("A1").GetValue();
There is a date in cell A1 that is copied to variable
dataValue , then pasted to the cell C3 and format is applied. Also I’ve added AutoFit method to avoid insufficient amount of space for the date that would cause date to be displayed like
#####. The result is:
Indeed, JS counts days from 1970 but VBA does from 1900, please correct me if I’m wrong.
Pardon me , but dont get why you mentioned VBA .
VBA is used in various text processors like MS Office, Libre Office, etc. It is a starting point, so to provide even experience with macros, in our editors date count starts from 01/01/1900 just like in VBA.