An NDA can continue indefinitely or end on a predetermined date. If a date is not specified, the information should remain confidential indefinitely.
Alternatively, you can specify a date for the duty of non-disclosure (the responsibility of keeping the information confidential) to end. This date can be when the relationship between the two parties ends, or it can be when the information no longer needs to be confidential because it will be in the public domain. Although, it should be noted that the duties of non-disclosure can extend beyond the formal end of the agreement. For example, trade secrets are considered valuable business assets and are generally protected indefinitely by UK law.
Also, an NDA will not be enforceable if the confidential information becomes publicly known (through no fault of the receiving party) because it can no longer be defined as confidential information.
For instance, imagine two inventors enter an NDA with a potential investor. The investor agrees to keep the details of the invention confidential until they can begin manufacturing and selling the new product. If one of the inventors gives away the secrets of the invention during an interview with a journalist, the information would be considered public knowledge, and the investor could not be held accountable by the inventors if that information is used by third parties.