The D7 Date module comes with 3 storage systems: https://www.drupal.org/node/1455576

Database-native date storage is

Called a 'datetime' field type in techno database speak. This format type is recomended for most installs because it takes advantage of the database's date handling functions without any conversion, which means faster queries.

Unfortunately the date field in D8 has been implemented as a varchar. This means that it isn't actually possible to directly sort or filter based on date. It may be possible to use a mysql function to do this or maybe even index it, but it would be better to just use the database native storage. I don't understand why it was decided to use varchar.

https://api.drupal.org/api/drupal/core!modules!datetime!src!Plugin!Field...

It seems obvious to me that we should be using datetime instead of varchar like the recommended option in D7. We would be able to sort and filter and also this would be indexed.

Comments

amateescu’s picture

Category: Bug report » Task
Priority: Critical » Normal
Status: Active » Closed (works as designed)

This was a deliberate decision made when the initial date-field-in-core patch was authored/reviewed/committed, see #501428-19: Date and time field type in core and https://groups.drupal.org/node/221254 for more background on it.

In any case, I really don't see how that decision made *all* Drupal 8 sites unusable to warrant the critical status for this issue?

And don't forget that core also provides a 'timestamp' field type: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!Plugin!Fiel... that you can use if you need integer storage.

damienmckenna’s picture

The most important comment in that discussion is this one from KarenS: https://groups.drupal.org/node/221254#comment-730579

As you were.