title: Trying to extract a date from a 5 or 6-digit number
body: <p>I am trying to extract a date from a number. The date is stored as the first 6 digits of a 11-digit personal ID-number (date-month-year). Unfortunately the cloud-based database (REDCap) output of this gets formatted as a number, so that the leading zero in those born on the first nine days of the month end up with a 10 digit ID number instead of a 11 digit one. I managed to extract the 6 or 5 digit number corresponding to the date, i.e. 311230 for 31st December 1930, or 11230 for first December 1930. I end up with two problems that I have not been able to solve.</p>
  <p>Let's say we use the following numbers:</p>
  <pre><code>dato &lt;- c(311230, 311245, 311267, 311268, 310169, 201104, 51230, 51269, 51204)
  </code></pre>
  <p>I convert these into string, and then apply the as.Date() function:</p>
  <pre><code>datostr &lt;- as.character(dato)
  datofinal &lt;- as.Date(datostr, &quot;%d%m%y&quot;)
  datofinal
  </code></pre>
  <p>The problems i have are:</p>
  <ul>
  <li>Five-digit numbers (eg 11230) gets reported as NA.</li>
  <li>Six-digit numbers are recognized, but those born before 1.1.1969 gets reported with 100 years added, i.e. 010160 gets converted to 2060.01.01</li>
  </ul>
  <p>I am sure this must be easy for those who are more knowledgeable about R, but, I struggle a bit solving this. Any help is greatly appreciated.</p>
  <p>Greetings
  Bjorn</p>