views:

30

answers:

1

I need to port this following from Oracle syntax to Postgresql.

Both FLO_END_DT and FLO_START_DATE are of type DATE in Oracle, and TIMESTAMP WITHOUT TIME ZONE in Postgresql:

SELECT TRUNC( TO_CHAR(ROUND(( FL.FLO_END_DT- FL.FLO_START_DT)* 24), '9999D99'), 2)
 FROM FLOWS FL

I am not familiar enough with Oracle to know what it is trying to accomplish.

Any ideas?

+1  A: 

Number of HOURS.

The END_DATE-START_DATE will give days, and the multiplication by 24 will turn it to hours.

This is then rounded and the result shown as a 9999.99 (but the bit after the decimal point will always be zero because of the rounding).

Finally the TRUNC will do an implicit conversion back to a number because TRUNC makes no sense for a string.

Whoever put that mess together should be taken out and &%@($^

Gary
haha at your last comment.
Grasper