The sentence is grammatical. As usual, one needs to consider context. Sentences are not spoken in a void. And they are not laboratory specimens to be dissected without regard to context.
I have been to London for two weeks
might seem ungrammatical is the following:
The basic meaning of I've been to a place (before) is that at some point in the past I went to a place but I am not still there at the moment of speaking.
I've been to London (before now)
is equivalent to
I've /gone to and returned from/ London (before now)
The speaker is not still in London. This can be because the speaker has gone to London and (a) returned to the starting point, or (b) went somewhere else. The before now is not necessary; I include it just to bring out the sense of the present perfect.
When we use the present perfect with for a specific duration, we usually do so to indicate the duration of an action begun in the past that continues to the moment of speaking, whether referring to a single continuous action, as in
I've read this book for two hours, and now I am putting it away and doing something else.
Or to a series of repeated actions:
I've read this book for two months and I still haven't finished it.
Since for two hours/months indicates the duration of an action or repeated action up to the moment of speaking
?I've been to London for two weeks
in the sense
?I've /gone to and returned from/ London for two weeks.
seems ungrammatical, since the speaker is not still in the process of /going to and returning from/ London.
However, the speaker is (still) in the state of been to London for some past duration.
If we were discussing how long a person has been to a certain place, either on one occasion or across more than one instance, the following questions are all valid:
Has anyone (ever) been to London for more than a week?
or even the more specific
Has anyone (ever) been to London for two weeks?
Note the ever is not necessary. One can ask those same to questions without ever and they mean the same. I include it just to show that the question is asking about a
We can drop ever and ask about a very specific past time:
Has anyone been to London for two weeks during this past month?
For any of the above questions, the following response is grammatical:
I've been to London for two weeks.
This is grammatical, even though the speaker is not still in London and we are using for a duration. This is because the speaker, at the moment of speaking, is *in the state of 'been to London' in the past.
This is also the meaning with the participle:
Having been to London for two weeks, I can (from my experience) say that it rains a lot.
Where have you been (recently)?
can elicit the grammatical response
I've been to London for two weeks
Last, with the present perfect, we can use just to indicate the immediate past:
I've just been to London
I've been to London just recently (or just now)
Adding a duration is fine:
I've just been to London for two weeks
I've been to London for two weeks just recently (or just now)
Of course, 'just' can mean "simply" rather than "recently", as in
I've just been to London for two weeks (I haven't done anything else)
I've (just/simply) been to London for two weeks; I did't do anything nefarious such as engage in drug smuggling during my trip.