From http://peoplesoftsqr.com/index.php/2009/10/sqr-functions/