As far as I know the only way to do this in iOS 6 or lower is to store the app version in the Keychain and/or user defaults during the first run of the app. Even then, it wouldn't cover all possible scenarios.
If you didn't, you might be using libraries that do this for you (e.g.: iVersion).