The chances of detecting virus are highest in the days surrounding the start of symptoms. Ideally samples should be taken from symptomatic individuals between days 1-5 from symptom onset. However, there are many cases when virus can be detected later into the illness. A negative test result is also useful, to tell you that there is no presence of virus on that swab. But please bear in mind that this may be a false negative and isolation guidelines should still be followed. Many institutions use two swabs, 24 hrs apart to confirm a negative case alongside other clinical information.
Please read the FAQs on PCR tests here.