“I’m dividing two numbers to convert ticks to days but Power Automate gives me only full days as a result, ignoring the decimal numbers!”
If you divide numbers in Power Automate, e.g. to convert ticks to days to get a time difference, you’ll use the div(…) expression. But there’s a small inconvenience using it. By default, if you divide two whole numbers, it’ll return a whole number. It won’t return a decimal result, just the whole number part. Instead of 0.5 you’ll get a 0, instead of 2.3 you’ll get 2, etc. That’s not very helpful, especially if you’re trying to calculate some percentages.
How do you then tell it to return also the decimal part of the result?
Use decimal number as an input
The reason is that the expression keeps the input data type. You entered two whole numbers (integers), it’ll return another whole number (integer).
Since the expression sticks to the original input type, you must change the input. Instead of using two whole numbers convert one of them into a decimal number (float). Applying the float(…) expression will convert the input number, and together with that also the division result. It doesn’t matter which input it’ll be, you can pick any of them.
Note: <…> is a placeholder, replace it including the < and >.
Following with the example from above, the difference between now and 12 hours ago is 0.5 days, not a 0.
When dividing numbers in Power Automate, you should always consider converting one of them into a decimal number (float). The result will be another decimal number and you won’t miss any piece of information (especially if you’re trying to calculate percentages).