Dave,

> I like Raymond's link, though.  I wonder if I couldn't strip the
> punctuation and convert to integer in the query, rather than parse out
> each octet?
>
> Hmmm...

What I'd recommend doing is storing the IP address in integer format in the
database (you can store the IP in octet format as well.) That way you just
need to sort by the int value.

Here's some code to convert an IP address to its integer value that I just
whipped up:

<cfscript>
sIp = "192.168.1.23";

iIpInt = (listFirst(sIp, ".") * 16777216) + (listGetAt(sIp, 2, ".") * 65536)
+ (listGetAt(sIp, 3, ".") * 256) + listLast(sIp, ".");
</cfscript>

Feel free to wrap it up in a UDF. Now when storing an IP address, just store
it's int value as well.

-Dan

[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to