www.fromthevalley.com.au

Converting string to numbers

What seems like a very easy thing to do, ie usually casting a string to an integer, if not done correctly in postgres can stuff your results up.

 

 Say we have a string which is "123" and we pass it through this postgres function: to_number(col_name,\'9999999\'), it will give me 123.

 if we then pass 123.4 through the same  function it will give 1234.

 

However, if we put it through this function to_number(col_name,\'99999D99\'), we will get 123.40

HOMEAJAXAPACHEBizphoneCSSDNSGeneralGraphicsHTMLHardwareJavascriptLinuxMACMS SQLMailMicrosoftOFFICE 365PerlPostgresSEOSocial MediaVMwareWindows 10