Board index » delphi » [Access] sorting IP Addresses

[Access] sorting IP Addresses


2003-12-06 01:45:37 AM
delphi162
I need to know how to sort IP addresses.
An order by doesn't sort them correctly.
I am currently using MS Access but may upgrade to MSDE.
I found this but don't know how to convert to Access:
select * from Table
order by
cast(parsename(ip,4) as int),
cast(parsename(ip,3) as int),
cast(parsename(ip,2) as int),
cast(parsename(ip,1) as int)
 
 

Re:[Access] sorting IP Addresses

"eshipman" <eshipman@yahoo!!!.com>writes
XXXX@XXXXX.COM...
Quote
I need to know how to sort IP addresses.
An order by doesn't sort them correctly.
If you store them as four separate 8-bit fields or as one unsigned 32-bit
field then they'll sort naturally.
Cheers,
Ignacio
 

Re:[Access] sorting IP Addresses

In article <3fd0cfbc$XXXX@XXXXX.COM>, "Ignacio Vazquez"
<ivazquezATorioncommunications.com>says...
Quote
"eshipman" <eshipman@yahoo!!!.com>writes
XXXX@XXXXX.COM...
>I need to know how to sort IP addresses.
>An order by doesn't sort them correctly.

If you store them as four separate 8-bit fields or as one unsigned 32-bit
field then they'll sort naturally.
Lo siento, dude, no can do.
 

Re:[Access] sorting IP Addresses

use the substr to pick out number , then inttostr to convert to int