This is a problem of modeling ballistics motion.
When a object is fired at at the angle of at the height of with acceleration of gravity being
Its displacement is . Notice that I said displacement because this is a type of problem which is a vector-valued function. This give you the position at any giving time. The other formula in physics just gives you the height at any given time. Now you must agree that knowing the position at any given time would mean you know its height at any given time. Thus, this formula is superior to the other one.
Try doing your problem with this formula, if you cannot tell me and I will try to do it for you.