How to implement a mysql date or datetime field correctly in hook_schema()? I have written a mymodule.install file which contains a schema definition to create a table in my database. This table contains two data fields. Theese fields will be populated by the users when they will fill in the specific content (example: to specific a publish date for a news). Now i didn't used the Date contributed module on purpose, cause i needed that theese two fields were on the same row in the database table for other reasons.

The hook_schema defines the two fields this way:

'pubblish_date' =&gt; array(
    'description' =&gt; t('The pubblish date for the single news'),
    'mysql_type' =&gt; 'datetime',
    'not null' =&gt; FALSE,
  ),
  'unpublish_date' =&gt; array(
    'description' =&gt; t('The unpublish date for the single news'),
    'mysql_type' =&gt; 'datetime',
    'not null' =&gt; FALSE,
  ),


The table is created correctly in the database, but i always get theese advice messages:

Field news_board.pubblish_date: no Schema type for mysql type datetime.
Field news_board.unpublish_date: no Schema type for mysql type datetime.
news_board.pubblish_date: no  type for Schema type :normal.
Field news_board.pubblish_date: no Schema type for type .
news_board.unpublish_date: no  type for Schema type :normal.
Field news_board.unpublish_date: no Schema type for type .

Seems strange to me cause I red on the documentation to use the mysql_type specification in order to store the datetime format in mysql database.

I know that Drupal supports natively timestamps and if you want to store a different date format you have to use specific definitions like mysql_type or pgsql_type according on the database yuo are using. 

In discussions I found online lot of people used mysql_type definition and from what I seen they solved the problem, so why it doesn't work for me?

Thanks a lot.
You should provide a fallback type (varchar) for the case that the database is not mysql.

'pubblish_date' =&gt; array(
  'description' =&gt; t('The pubblish date for the single news'),
  'type' =&gt; 'varchar',
  'mysql_type' =&gt; 'datetime',
  'not null' =&gt; FALSE,
),
'unpublish_date' =&gt; array(
  'description' =&gt; t('The unpublish date for the single news'),
  'type' =&gt; 'varchar',
  'mysql_type' =&gt; 'datetime',
  'not null' =&gt; FALSE,
),


However, the messages you see come from the Schema module. This problem is already recorded as issue #468644.

The implementation of the mysql datetime in your schema is fine. You can safely ignore these messages.  I would say that these "advice messages" are caused by a bug in the Schema module.