The way it works for most if not all credit cards that I've had is this: If you started the billing period with a zero balance, and you pay the amount shown on the statement in full, there is zero interest. But if you started the period with some money owed, or if you do not pay all new charges shown on the statement in full, then you pay an amount of interest equal to the monthly interest rate times the average daily balance. The average daily balance is calculated by adding up your balance as of the end of each day, and then dividing by the number of days in the billing period.
Addendum: As Dilip points out, technically it's not if you start the statement period with a zero balance, but rather if you pay all the charges from your previous statement by the due date.
Note that the way this formula works, there's a big difference between paying the entire balance and paying even one dollar short. If you started with a zero balance, on the first day of the billing period you made a charge for $1000, you had no other charges, and you paid $1000 on the due date, your interest will be $0. But if you pay $999 on the due date, you will be charged interest on ($1000 x 29 + $1) / 30 dollars (assuming 30 days in the period).
So if you start with a zero balance and pay in full, then you can pay any time up to the due date and you'll pay zero interest. Whether you pay on the due date or two weeks in advance makes no difference.
But if you began with a balance, or if you can't afford to pay in full, then the sooner you pay, the less interest you will be charged.
You definitely want to avoid waiting to pay until after the due date, because then you typically get hit with a substantial late fee. If you can't afford to pay the whole amount, at least make the minimum payment so you won't get the late fee, then pay the rest later.
If you're consistently maintaining a zero balance, then you can wait to the lost possible day to pay. Otherwise, you should pay as soon as possible to get the minimum interest charge. Though personally, I avoid waiting until the due date to make a payment, as what happens if I forget, or something comes up that prevents me from making the payment? If you're mailing in payments, you don't want the post office taking an extra day or two to cause you a late charge. Etc.
If you keep your money in an interest-bearing account, there's some advantage to delaying making payments. But in the U.S. anyway, the interest you can get on a liquid account is usually so small as to not be worth even thinking about, usually a fraction of a percent. So normally, you should just pay as soon as you can.
It's possible that the terms on your credit card are different from what I've had, especially if you do not live in the U.S. If you want to be sure you should read any terms or contract they send you carefully. (Of course that's always a good idea. When would it be good advice to tell someone, "Oh, go ahead and sign without reading the contract"?) But in general, I'm hard pressed to think of any likely terms where it would be to your advantage to delay paying. The only question would be if there is something else you can do with your money that benefits you more than it costs you to delay paying. And in real life, I think the answer to that would be rarely or never.