Views sorting a custom field I've added a custom field to my view using hook_views_data:

/**
 * Implements hook_views_data().
 */
function homepage_views_data() {
  $data['homepage']['table']['group'] = t('Recency field');
  $data['homepage']['table']['join'] = array(
    // Exist in all views.
    '#global' =&gt; array(),
  );

  $data['homepage']['recency_field'] = array(
    'title' =&gt; t('Recency'),
    'help' =&gt; t('Display a calculated recency date'),
    'field' =&gt; array(
      'handler' =&gt; 'views_handler_recency_field',
      'click sortable' =&gt; TRUE,
    ),
    'sort' =&gt; array(
      'handler' =&gt; 'views_handler_sort_date',
    ),
  );

  return $data;
}


Right now, my field is simply returning the value of node_created. In my field handler:

/**
   * Render callback handler.
   *
   * Return the markup that will appear in the rendered field.
   */
  function render($values) {
    $output = $values-&gt;node_created; 
    return $output;
  }


I can add my custom field to a View no problem. But after adding it as a sort field, I get:


  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'recency_field'
  in 'field list'


The query looks like this:

SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created, recency_field AS recency_field
FROM 
{node} node
WHERE (( (node.status = '1') ))
ORDER BY recency_field ASC


Does views_handler_sort_date need to work with a real database value?
I believe views lets the database do the sorting, so unless your field exists inside the database, the database controller won't recognise it which is what your error message basically says.