There is know way to know because God’s answers are not always clear. Sometimes they are clear. You pray for something and clearly get it some time later. Most times it is unclear. Prayer is very much involves trust (or faith). We have to trust that God is going to do what’s best for us. That might mean he answers a prayer exactly as we want or simply answers with a “no” to our request or maybe answers it many years later (perhaps even after our death).
If God says no, he must have a reason for it. Maybe whatever it is we want will pull us further from God rather than closer. In the case of years going by before an answer, a parent could be praying for years for the conversion of a child, which doesn’t happen until the child is on their death bed, 20 years after the parent has passed away. God works on his own time, so patience is another good virtue to have with prayer.