0

I don't have access to a client database, but need to know how a "Date" CCK field stores its information.

I'm using MySQL, and this easily found in the structure of the table. Anyone use Postgres and can check?

Is it a timestamp or a date?

2

Why do you need access to the database for this information?

Have you looked here? http://drupalcode.org/project/date.git/blob/b7502f3a86628e5c4995c01f20ac64d5cee5888b:/date.install

/**
 * @file
 * Install, update and uninstall functions for the Date module.
 */

/**
 * Implements hook_field_schema().
 */
function date_field_schema($field) {
  $db_columns = array();
  switch ($field['type']) {
    case 'datestamp':
      $db_columns['value'] = array(
        'type' => 'int',
        'not null' => FALSE,
        'sortable' => TRUE,
        'views' => TRUE,
      );
      break;
    case 'datetime':
      $db_columns['value'] = array(
        'type' => 'datetime',
        'mysql_type' => 'datetime',
        'pgsql_type' => 'timestamp without time zone',
        'sqlite_type' => 'varchar',
        'sqlsrv_type' => 'smalldatetime',
        'not null' => FALSE,
        'sortable' => TRUE,
        'views' => TRUE,
      );
      break;
    default:
      $db_columns['value'] = array(
        'type' => 'varchar',
        'length' => 20,
        'not null' => FALSE,
        'sortable' => TRUE,
        'views' => TRUE,
      );
      break;
  }
  // ... more stuff

The answer to your question is that depending on the Drupal "Date" value you're storing it -- for Postgres it is 1 of the following values:

  • (drupal field of) datestamp = int DBMS field
  • (drupal field of)datetime = timestamp without time zone DBMS field
  • (other drupal field of) date = varchar DBMS field analyzed by Date module on save and usage

EDIT

My answer is for Drupal 7. The same module API can be referenced for Drupal version 6 if needed. You didnt specify what version of Drupal you are using and "CCK" can be apart of both.

  • The CCK field in question appears as "Date" on the content type page. (As opposed to "Date (ISO)" or other options) In MySQL, it's stored as a datetime, so at looking this, it must indeed be the Postgres data type 'timestamp without time zone' – mikeDOTexe Aug 7 '13 at 23:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.