title: Inverse function of FormatDateTime
body: <p>I am looking for a function to reverse <strong>any</strong> string (<code>YYYYMDD</code>,<code>YY/MM/DD</code>,<code>YYMMDD</code>,...) created by the function <a href="http://www.delphibasics.co.uk/RTL.asp?Name=FormatDateTime" rel="nofollow noreferrer">FormatDateTime</a> to datetime.</p>
  
  <p>example</p>
  
  <p>I have a string-date in format <code>YYYYMMDD</code>created by <code>FormatDateTime</code></p>
  
  <pre><code>mydatestr:=FormatDateTime('YYYYMMDD',Mydate); 
  </code></pre>
  
  <p>now how I can convert mydatestr to <code>DateTime</code> again?</p>
  
  <p>UPDATE</p>
  
  <p>these functions </p>
  
  <pre><code>function StrToDate(const S: string): TDateTime; overload;
  function StrToDate(const S: string;
    const FormatSettings: TFormatSettings): TDateTime; overload;
  
  function StrToDateTime(const S: string): TDateTime; overload;
  function StrToDateTime(const S: string;
    const FormatSettings: TFormatSettings): TDateTime; overload;
  </code></pre>
  
  <p>do not support passing a string with the format to convert.</p>
  
  <p>I am looking something like this </p>
  
  <pre><code>Mydatetime:=InvFormatDatetime('20091225','yyyymmdd');
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Mydatetime:=InvFormatDatetime('20090108','yyyyddmm');
  </code></pre>