Search

Top 60 Oracle Blogs

Recent comments

mod()

Here’s a little trick I’ve only just discovered (by accident). What’s a tidy way to extract the fractional part from a number ?
Running 11.1.0.6 (I haven’t checked earlier versions yet – or looked at the manuals for the definition of the mod() function):

SQL> select mod(1.34,1) from dual;

MOD(1.34,1)
-----------
        .34

1 row selected.

SQL> select mod(-1.34,1) from dual;

MOD(-1.34,1)
------------
        -.34

I really didn’t think it would make sense to use an expression like mod(p,1) – but it’s pleasant surprise that is does what it does.