Ideally it should not take more than 3-4 hours to transfer shares from once Demat Account to another.
This also depends on the repository. There are two repositories, viz: NSDL & CDSL. If the transfer is done from an NSDL account to a CDSL account, it would take the stipulated 3-4 hours. If the transfer is from one CDSL account to another or one NSDL account to another, then the transfer could be much faster - around 30 minutes or less.
PS: - This is the time taken after your depository participant (DP) gets the Transfer Instruction Slip from you and processes the action.