New water heater sometimes cold, sometimes hot
Most water heaters upon initial start-up can take several hours to heat the tank water to the setting on the thermostat. Also, if the setting is not at the hottest temperature and it is a large tank 12 hours isn't unreasonable.   You should also be aware that if the entire tank of hot water is consumed for say a long shower it will take the incoming water awhile before it is heated to the set temperature.   If you still feel that there is something mechanically at fault with the new water heater than there is only very few parts that can not function. The first is the thermostat that controls the water temperature. You may have one that is faulty or intermittent. Second is the heating element(s). These actually are responsible for heating the water. They work by becoming extremely hot when electricity is applied to there terminal ends. The heat is then transferred to the surrounding water until the thermostat switches the power off at the proper setting. Heating elements will fail eventually and need to be replaced with one of the same wattage rating.   Since the appliance is so new and working on it will void the warranty (and can be dangerous) you should first contact the installer (if any). It is possible an installation step was over-looked. Next, contact the store from where it was purchased. Most reputable stores will readily accept a faulty appliance for refund with only a receipt of purchase.