We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


Covert Mac Addresses to Integer — Vertica Forum

Covert Mac Addresses to Integer

Hi, I want to covert MAC address to integer format. They are in the form like below -

1e:07:02:15:3a:88
1e:07:02:1b:64:ab

I used the following query to convert them to integer -

Select hex_to_integer(MAC) from Network_table;

It is showing me the following error -

Invalid input syntax for numeric: "0x1e:07:02:15:3a:88"

I think its because the address contains ":" symbols. Any idea how can I overcome this problem?

Comments

  • Jim_KnicelyJim_Knicely - Select Field - Administrator

    Maybe try the REPLACE function to get rid of the colons?

    dbadmin=> select hex_to_integer(replace('1e:07:02:15:3a:88', ':', ''));
     hex_to_integer
    ----------------
     33015448550024
    (1 row)
    
    dbadmin=> select hex_to_integer(replace('1e:07:02:1b:64:ab', ':', ''));
     hex_to_integer
    ----------------
     33015448954027
    (1 row)
    

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file