title: Any alternative to MONTH() and YEAR() functions which are common to both MySQL and PostgreSQL
body: <p>Writing queries (a sql file) that can run both in MySQL and PostgreSQL, everything is OK so far except the following:</p>
  
  <pre><code>SELECT MONTH(Date), YEAR(Date) FROM Ticket;
  </code></pre>
  
  <p>for extracting the month number (9,10,11 ..) and year (2011, 2012..) from the Date column (yes thats true, I cannot change the name of this column)  in the Ticket table. It works fine in MySQL but when I run the query in PostgreSQL, it gives the following error message for both MONTH() and YEAR().</p>
  
  <pre><code>ERROR:  function month(date) does not exist
  HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
  </code></pre>
  
  <p>After researching a little bit I came along some other functions that will do the job in Postgres, but I am afraid those might not work in MySQL. Strongly looking forward for any possible solution.</p>