The code below shows the length of the diagonal in pt, how to show it as cm with 2 digits?
\documentclass[convert,border=10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows, calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (3cm,3cm);
\draw[latex-latex] (A) -- (B) node[pos=.5,yshift=.2cm, inner sep=1mm, outer sep=0mm,
insert path={let \p1=($(B)-(A)$),\n1={veclen(\x1,\y1)} in},
sloped,] {\n1};
\draw[red!90] (A) grid (B);
\end{tikzpicture}
\end{document}

\pgfmathparse{\n1/1cm}\pgfmathresult cminstead of\n1as node text. See: https://tex.stackexchange.com/a/99557/47927 – Jasper Habicht May 29 '23 at 22:41