title: Store full date or just an year in Database
body: <p>I am working on a project where there are bunch of dates which I need to store in a database (MySQL).</p>
  
  <p>The problem is, some dates are full, but some dates are just only year.</p>
  
  <p>For example, the dates are like this:</p>
  
  <ul>
  <li>20 January 1980</li>
  <li>2011</li>
  <li>25 February 2012</li>
  <li>2008</li>
  </ul>
  
  <p>I am using the function <code>date()</code> and <code>strtotime()</code> function in PHP to convert the dates in <code>Y-m-d</code> format. The full dates are converted successfully, but the dates with just only an year is converted to today's date which is wrong.</p>
  
  <p>The questions are:</p>
  
  <ul>
  <li>How to successfully determine which is a full date and which is just only an year in PHP and then apply the <code>date()</code> and <code>strtotime()</code> function to the full date only?</li>
  <li>How to save these variations (full date and only year) in database? (if it is possible in a single column)</li>
  <li>While fetching from the database, how to know whether the date is full or just an year and display it accordingly?</li>
  </ul>
  
  <p><strong>Edit:</strong></p>
  
  <p>Confused. I will be doing operations on date such as sorting date-wise which will include both full and year only dates. Whether to:</p>
  
  <ul>
  <li>Store year as 1990-00-00 and check for the zeroes while retrieving?</li>
  <li>Store year as 1990-01-01 and another boolean field isYear?</li>
  <li>Store year, month and day as integers in different columns?</li>
  </ul>