Usually, white refined sugar packets come with a shelf life of 2 years printed on them but technically, sugar can last much more than that, if stored properly. Use a dry and clean jar to store sugar and always use a dry spoon to scoop it out. If the sugar starts crystalizing and a damp smell comes from it, then you need to throw it away as it might have come in contact with a wet spoon or even humidity.
Disclaimer: It is best to use foods before their date of expiry. The above-given foods are safe for consumption if they don’t look or smell bad. If they do, it is best to discard them right away.