Cell formatting question lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- daveinhull · 2022-02-01 22:20 Hi, A quick question. If I format a cell with, say Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Grid.NumberFormat[1,20] := 'mmm/yy'; would there be any difference if I typed in that cell or set the contents of the cell in code? It seems, unless I've got something wrong, that if I type, say 1/12/21, I get what I would expect, Dec/21. But, if I set the cell contents to '1/12/21' with Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Grid.cells[1,20]:= '1/12/21'; all I get is 1/12/21, the formatting doesn't seem to take effect. Is this correct? Thanks Dave ---------------------------------------------------------------------- wp · 2022-02-01 23:59 Quote from: daveinhull on February 01, 2022, 11:20:10 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Grid.cells[1,20]:= '1/12/21'; all I get is 1/12/21, the formatting doesn't seem to take effect. Doing this puts a string into the cell - there is no attempt to convert it to a date. But when you assign a TDateTime it works: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Grid.Cells[1,20] := EncodeDate(2021, 1, 12); ---------------------------------------------------------------------- daveinhull · 2022-02-02 09:33 Hi wp, Yes it does't attempt to put a string into the cell, so I will change it to a TDateTime and give it a try. Thanks Dave