Depending on the type a few days to a lifetime 🙁
It’s normal for people to feel depression and anxiety. It’s important that people suffering from them get help if the symptoms become severe. I’m not an expert on these things so I can’t impart medical advice.
From personal experience I can say that if you’re suffering from either of these, they won’t impact your ability to do science 🙂 the community is very nurturing and takes care of people. https://www.nhs.uk/Conditions/stress-anxiety-depression/Pages/mental-health-helplines.aspx
A website with some helpful contacts.
Anxiety and depression can last for a long time if you don’t talk to someone about it. If you think you have anxiety or depression you should talk to your doctor. There are medicines that you can take to help too.