June 28, 201312 yr I'm sure that the sorting of IP numbers has been answered many times over, but I've been searching with no luck. I've got a filed that contains IP numbers.. ( 192.168.1.1 and 192.168.1.12) I've made the filed a text filed as number filed does not view correctly. In doing so the IP do not sort correctly if you I do not enter them with leading 0's. 192.168.001.001 192.168.001.012 is there away around not using the leading 0's Thanks
June 30, 201312 yr Here is a custom function (by Theo Ros) that should do what you want: http://www.briandunning.com/cf/279 It's basically adding the zeros for you with a custom function so you do not need to do it manually. /*------------------------------------------------------- Returns a sortable textual representation of an IPaddress. To text-sort IP addresses, you will have to reformat the triplets. Here it is done by adding leading zeros to them. This will result in textvalues that will sort correctly, for instance in a portal-sort solution. Syntax: IPToSortableText ( IPaddress ) Return type: Text IPToSortableText ( Get ( SystemIPAddress ) ) returns ip like "192.168.000.001" Theo Ros ----------------------------------------------------------*/ Let ( ip = Substitute ( TrimAll ( IPaddress ; True ; 3 ) ; "." ; "¶" ) ; Right ( "000" & GetAsNumber ( LeftValues ( ip ; 1 ) ) ; 3 ) & "." & Right ( "000" & GetAsNumber ( MiddleValues ( ip ; 2 ; 1 ) ) ; 3 ) & "." & Right ( "000" & GetAsNumber ( MiddleValues ( ip ; 3 ; 1 ) ) ; 3 ) & "." & Right ( "000" & GetAsNumber ( MiddleValues ( ip ; 4 ; 1 ) ) ; 3 ) )
Create an account or sign in to comment