Devin Posted June 28, 2013 Posted June 28, 2013 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
HALBURN Posted June 30, 2013 Posted June 30, 2013 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 ) ) 1
Recommended Posts
This topic is 4175 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now