I have some shares of visa stock and today (monday 28th) at 5:00 P.M. they are going to announce how they did for the 2nd quarter. The last few days the stock has been rising at a fast rate probably for that exact reason. When should i sell to maximize profits? also if you know, how long do i have to hold on to a stock to get their dividends?

If you are trading to maximize profit and do not know if they will report good earning or if they will not meet expectations a good strategy would be to sell half before they report and then wait to see if the rest will go up or down. It’s a gamble.
Dividends are paid to shareholders of record as of any given date. If you buy the shares after the ex-dividend date you will not get the dividend. Just remember that once the dividend is paid the shares will go down and usually will bounce back up but sometimes you have to wait for them to bounce back. I got $4,500 from Dean Foods (DF) and the stock was not a good trade. It is way down now.
I know this wont be the ideal answer but it really depends on the result of the 2nd quarter earnings. If its better than expected, which by the fact that its going up over the last few days could well be the case then holding on would probably be the best bet. However, if you have already made a profit on your shares then maybe selling out some before the announcement to lock in some profit would be worthwhile.
Just because the share is going up pre earnings doesn’t mean that it will continue to do so after the result is common knowledge. If this is a long term investment it may be worth holding on, but if the result comes out bad or worse than expected then you may be kicking yourself that you didnt get out of some shares before hand.