Morning all,
This post is 3/4 a 'Tip' with a 1/4 a question to see if anybody can answer my knowledge gap. I had a requirement to be able to report on the number of Hours and Minutes between two days in a presentable format; after searching around I found a couple of formula's and, after some testing, have consolidated the approaches and added some additional bits in of my own:
NumberVar DateDifference;
StringVar TimeDifference;
DateDifference:= DateDiff('n',{@Start DateTime},{@End DateTime});
TimeDifference:= CStr(Round(DateDifference\60),"#")+' Hours '+
CStr(Round(DateDifference MOD 60), "00")+' Minutes';
TimeDifference;
There are two questions which I couldn't find the answer to by searching online and these are:
1) In the below bit of the formula, what is the "#" doing? As far as I can tell it's setting the decimal places to zero but I wasn't sure if the hash tag had another use?
TimeDifference:= CStr(Round(DateDifference\60),"#")
2) In the below bit of the formula, the "00" has to be used as opposed to the usual ROUND Criteria (E.g. 0, 1, 2) as it produces an error ("Bad number format string."). My assumption is that the "00" is doing the same as a "2" would; is there a reason that it has to be set as "00" though?
CStr(Round(DateDifference MOD 60), "00")
Hopefully this will help somebody and hopefully somebody can answer my outstanding two questions :-)