title: SQLAlchemy ORM DateTime with specific format
body: <p>I have a table which stores a datetime value in the following format: (e.g.) 20160213145512. Unfortunately, SQLAlchemy gives me no chance to specify the format used to store a datetime value into the database with sqlalchemy´s DateTime type.</p>
  
  <p>Therefore, i have created the following dataype:</p>
  
  <pre><code>class Timestamp(TypeDecorator):
      impl = String(14)
  
      def process_bind_param(self, value, dialect):
          if isinstance(value, datetime):
              value = '%04d%02d%02d%02d%02d%02d' % (value.year,
                                                    value.month,
                                                    value.day,
                                                    value.hour,
                                                    value.minute,
                                                    value.second)
          return value
  
  
      def process_result_value(self, value, dialect):
          if value:
              return datetime(year=int(value[0:4]),
                              month=int(value[4:6]),
                              day=int(value[6:8]),
                              hour=int(value[8:10]),
                              minute=int(value[10:12]),
                              second=int(value[12:14])
                              )
  </code></pre>
  
  <p>I do not use strftime and strptime for performance reasons.
  What I am now able to do is the following:</p>
  
  <pre><code>class TestTable(Base):
      __tablename__ = "TESTTABLE"
  
      id = Column(Integer, primary_key=True)
      timestamp = Column(Timestamp)
  </code></pre>
  
  <p>Insert row by defining the datetime via a datetime object:</p>
  
  <pre><code>session.add(TestTable(timestamp=datetime(year=2016, month=2, day=3, hour=2)))
  </code></pre>
  
  <p>Or inserting a row by defining datetime as a string:</p>
  
  <pre><code>session.add(TestTable(timestamp="20160203031422"))
  </code></pre>
  
  <p>So far, so good. 
  But the following is not working as expected:</p>
  
  <pre><code>session.query(TestTable).filter(TestTable.timestamp.year == 2016).all()
  </code></pre>
  
  <p>If I am runnning this code snippet I get this error:</p>
  
  <pre><code>AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with ORDERS.dz_statakt has an attribute 'year'
  </code></pre>
  
  <p>However this works:</p>
  
  <pre><code>session.query(TestTable).filter(TestTable.timestamp.startswith("2016")).all()
  </code></pre>
  
  <p>Until now I was not able to solve this problem. I guess I am missing something in my own Timestamp class.</p>
  
  <p>Is this possible at all?</p>