For the recent questions about this here are a couple of methods for encoding/decoding long values that will be sorted into order by a range query
public static String encodeLong(long num) { String hex = Long.toHexString(num < 0 ? Long.MAX_VALUE - (0xffffffffffffffffL ^ num) : num); hex = (num < 0 ? "N" : "P")+"0000000000000000".substring(0, 16-hex.length()) + hex; return hex; } public static long decodeLong(String hex) { long num = Long.parseLong(hex.substring(1,17), 16); return hex.charAt(0) == 'N' ? (Long.MAX_VALUE - num) ^ 0xffffffffffffffffL : num; } Hope this helps Mike www.ardentia.com the home of NetSearch