I think you’re mistaken about where the error is occurring.
The error “variant does not contain a container” reports that you used a variable in a Forall statement which isn’t an array or list. There might be other statements that might generate the same error, but the NotesDateTime constructor and assignment here, neither of them require a container. The NotesDateTime constructor is looking for a string. The assignment is looking for a NotesDateTime – both scalars.
I might also point out the NotesItem.DateTimeValue property, which is a more efficient way to assign your variable.
It sounds like your “doc” object is not getting set or your CreatedField is blank - add some error checking and step through your code in debugger to see if Doc is getting instantiated.