Sorry! the conversion is correct but it is in reverse order.
The select statement return :
1A:FC:90:48:30:00
 
and I checked the MAC Address:
 
 00:30:48:90:fc:1a
How to change it to correct order or may be the number 29672054730752  needs to 
be reverse.
Once again thanks for the help,
JP



----- Original Message ----
From: Joanne Pham <[EMAIL PROTECTED]>
To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
Sent: Friday, September 12, 2008 10:58:31 AM
Subject: Re: [sqlite] Convert the MAC address from integer to characters.

Thanks a lto Dennis!
But I got the value in reverse order and not correct with the 1A vs 1B.
Select statement return 
1A:FC:90:48:30:00

but When I checked the MAC address on the server the return value is
 00:30:48:90:fc:1b

May be the number is not correct  29672054730752 ?
Or our conversion is not correct.
Thanks,
JP


----- Original Message ----
From: Dennis Cote <[EMAIL PROTECTED]>
To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
Sent: Friday, September 12, 2008 10:12:37 AM
Subject: Re: [sqlite] Convert the MAC address from integer to characters.

Joanne Pham wrote:
> Thanks a lot for quick respond.
> I would like to have the format as : 00:15:C5:F1:1D:45 
> Please help me how to convert this number 224577687400448 to 
> this format 00:15:C5:F1:1D:45 

This should do the trick. It's not pretty in SQL, and it might make more 
sense to do it in your application's programming language, but it does work.

    select
        substr('0123456789ABCDEF', ((mac >> 44) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 40) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 36) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 32) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 28) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 24) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 20) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 16) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 12) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 8) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 4) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 0) & 15) + 1, 1)
        as 'MAC Address'
    from t;

This assumes that the table t has an integer column mac that hods the 
mac address to be displayed.

HTH
Dennis Cote
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



      
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



      
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to