What Is a Grace Period on a Credit Card?
What it actually is
A grace period is the window between making a purchase and when you actually have to pay for it without any interest applying, provided you clear your full statement balance by the due date. It isn't a fixed number of days from your purchase, it's the gap between your billing cycle's statement date and its due date, plus however many days were left in the cycle when you made the purchase.
Why it varies so much, 20 to 50 days
Spend right after your statement date and you get the longest possible grace period, roughly the full length of your billing cycle (commonly around 30 days) plus the 15 to 20 days between statement date and due date, adding up to as much as 45 to 50 days. Spend right before your statement date, and that same purchase might only get a week or two of grace before it shows up on a bill that's due soon. This is why the timing of a large purchase within your billing cycle genuinely matters if you're trying to maximize interest-free time.
Two identical purchases, two very different windows
Say your statement date is the 5th of the month and your due date is the 25th. Buy something on the 6th, the day after your statement closes, and that purchase won't appear on a bill until the statement generated on the following month's 5th, due on the 25th after that, roughly 49 days from purchase to payment deadline. Buy the identical item on the 4th instead, one day earlier, and it lands on the statement closing that same day, due on the 25th of that same month, as little as 21 days later. Same product, same price, same card, a 28-day difference in how long you actually have, purely from which side of one date the purchase fell on.
How you lose it entirely
The grace period only exists if you pay your full statement balance by the due date, every cycle. Pay even the minimum due instead of the total, and the grace period disappears, not just for the unpaid balance, but for every new purchase you make going forward, which starts accruing finance charges from its own transaction date. Once lost, the grace period comes back only after you've paid a full statement balance in full again.
What it doesn't cover
Cash advances never get a grace period, interest on those starts the moment the cash leaves your card, regardless of your payment history. The grace period is strictly a purchase-transaction benefit.