Random delay

Could anyone please tell how to get an random delay in the program between two limits of delay?( For example between 500 ms to 1000 ms )

I hate delay(…) and prefer millis(), but what about the untested

delay(random(500, 1001)) ;


I don’t know why you would want to do this, but there might be a good reason.
Notice that the delay used wastes the considerable power of an Arduino for half a second to a full second.