Your error, I would guess, occurs on one of these three lines:
string sub1 = (Convert.ToString(dateTimeDate.Value)).Substring(3, 2);
string sub2 = (Convert.ToString(dateTimeDate.Value)).Substring(8, 2);
sub = (Convert.ToString(sub)).Substring(0, 3);
Before you attempt any substring function, check the length of the string you are trying to extract. If it is less than either the index you are starting with or the index plus X characters you are trying to extract then it will fail.
For example you could try:
string sub2 = (Convert.ToString(dateTimeDate.Value));
sub2 = sub2.length > 9 ? sub2.Substring(8, sub2.length > 11 ? 2 : (sub2.length-1)-8) : "";
What this would do is check to see if sub2 has a length more than 9 (i.e. it has a possible starting index of 8 as per your code. Then it looks to see what length it can extract, be it 1 or 2 characters. If it cannot extract the sub string it sets sub2 equal to "".
I'm not 100% on the code but its just a concept for you to work with.