Home / Search/ Language Reference/ Functions/ Scalar Functions/ INET Functions/format_ipv4

format_ipv4

The format_ipv4 function parses input with a netmask and returns string representing IPv4 address.

Syntax

format_ipv4( Expression [, PrefixMask ] )

Arguments

  • Expression: A string or number representation (in big-endian order) of the IPv4 address.
  • PrefixMask: An integer from 0 to 32 representing the number of most-significant bits that are taken into account. If argument isn’t specified, all bit-masks are used (32).

Results

If the conversion is successful, returns a string representing IPv4 address.

If the conversion fails, returns an empty string.

Examples

  • format_ipv4('192.168.1.255', 24) returns as "192.168.1.0"
  • format_ipv4(3232236031, 24) returns as "192.168.1.0"