This quote in its entirety reads,
"There is a tide in the affairs of men, which, taken at the flood, leads on to fortune; omitted, all the voyage of their life is bound in shallows and in miseries".
It is actually taken not from Shakespeare's Hamlet, but from Julius Caesar, Act 4, Scene 3, lines 217-221.
The quote is spoken by Brutus, during the civil war which occurred after the assassination of Caesar. The people have risen up against Brutus and Cassius, who were instrumental in orchestrating Caesar's death, and at the time the quote is said, the two are in Greece, where they have raised an army and are preparing to face Octavius and Antony in a decisive battle. Brutus, who wants to march now to Philippi to meet the advancing forces, addresses his words to Cassius, who thinks that they should stay where they are and let the enemy come to them. Brutus is in effect arguing that the time is right, and their opportunity is now; if they do not take advantage of it, it will not come again. Cassius, as is his habit, accedes to Brutus's wishes. They agree that tomorrow, in the early morning, they will rouse their forces and take the initiative, proceeding to Philippi.
this quote is not from Hamlet, "there is a tide in the affairs of men," is said but brutus, this is in Julius Caesar...
It is from Julius Caesar spoken by Brutus.