How are Day Trades calculated?

Day trades are calculated on closing transactions. For example, if you buy 100 shares of XYZ stock five separate times throughout the day, and sell 500 shares at one time this is considered one day trade. If you buy 500 shares of XYZ stock in a single trade, and then sell 100 shares in five separate trades, then this is considered 5 day trades.