title: Create a unique number based on date and autoincremented number
body: <p>I need to generate the incremental numbers based on date.
  numbers created on a previous date (say  06-Jan-2014) should not be greater then numbers created on the coming dates (say 08-Jan-2014).
  how to add it with date ?
  I tried the down one but in few cases it is failing</p>
  
  <pre><code>static long num =1;
  public long GetUniqueNumberAsPerDate(DateTime date)
  {
      string dateStr = date.ToString("yyMMdd");
      long alwaysIncrementeduniqueNum = num + 1;
  
      return Convert.Int64(dateStr + alwaysIncrementeduniqueNum.ToString());
  }
  </code></pre>
  
  <p><strong>Failing cases</strong></p>
  
  <p>Date Passed : 2014-06-06
  Num : 14
  Number Created : 14060614</p>
  
  <p>Date Passed : 2013-06-06
  Num : 132
  Number Created : 130606132 ( which is greater then 14060614)</p>
  
  <p>The function can be called at same time by multiple applications. so the dateTime (even milliseconds) can be same
  Any solution to this problem</p>