Here I have this query to have sums for resource usages per hour.
SUM (CEIL(EXTRACT(EPOCH FROM (ended_at - started_at)/60/60))*price_hourly)
I calculate with having UNIX time between eneded_at & started_at timestamp and use ceil function returns the smallest integer value, and then multiply by price_hourly. So that I can count operating time even it is so small.
But I found out if timestamp is milliseconds like 2016-03-09 20:20:0.000010 This doesn’t behave like what I expected.
ended_at = 2016-03-09 20:20:00.000000
started_at = 2016-03-09 20:20:0.000001
price_hourly = 10
comes out 0 ( expected 10 )
Timestamp has some limitation to calculate such a small digits like this? Maybe this part ( 0.000001 / 60 /60 ) drops the last .1
Do you have any idea to get the last .1 and get digits correctly? or Do you know more nice way to do the exact same thing?