If not executed during the day, all day orders are cancelled at the end of the day. A GTC order remains open for 30 days unless the order is either executed or cancelled by you. The GTC qualifier can be placed on a limit, stop market, or stop limit orders. The order does not have to be filled immediately as the execution can occur during the course of the trading day. Since a number of orders can reach the marketplace at approximately the same time, a standard for the priority of orders has been set to determine which orders will be executed first.
Price is the first priority.
The best bid and best offer will be executed first. If you have the same price as others, time is the next priority. Your order has priority over orders entered after yours. If your order arrived with the same price at the same time, size of orders will receive priority. Generally, the larger order receives priority.