title: How to store Datetime to a variable in VBA to save in Excel database
body: <p>I have this Datetime stamp that I got from a textbox(Named: DateTime), which I want to save in my Excel database.</p>
  
  <p><a href="https://i.stack.imgur.com/ULtpT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ULtpT.png" alt="DateTime Stamp on Textbox"></a></p>
  
  <p>I have researched online and on this website to no avail. One of the answers here says that I need to parse the DateTime first before saving it to a variable. So I followed the suggestion.</p>
  
  <pre><code>    Dim I1 As Variant
      Dim ConvertDate As Date
  
      I1 = Split(DateTime, Space(1))
      ConvertDate = DateValue(I1(4) &amp; Space(1) &amp; I1(1) &amp; ", " &amp; I1(2)) + TimeValue(I1(3))
  </code></pre>
  
  <p>I used the code above but it is making a Subscript out of Range error. When I hover in each I1, the I1(4) is saying  "I1(4)=. It is not reading the Month. I1(1) says the day, I1(2) the Year and the I1(3) the time. </p>
  
  <p>Is this the best method in saving DateTime as a variable? What error did I make? </p>