Failed SELECT value from Date field (single value) I've installed date module. the field data stored in field_data_field_date_start_rent. The field dont have multiple values

I want to select field_date_start_rent_value.

So, I'm testing SELECT it and UPDATE to other date field. It not works.

Below is the SELECT, but I'm using text field to UPDATE to see if it works:

$nid = $node-&gt;nid;
$startrent = db_query("SELECT field_date_start_rent_value FROM {field_data_field_date_start_rent} WHERE entity_id = $nid")-&gt;fetchField();
$endrentf = db_query("UPDATE {field_data_field_cubagan} SET field_cubagan_value = $startrent WHERE entity_id = $nid");
return $endrentf;


If using the same SELECT query on integer field, it works without problem. I think it must have something different in the SELECT query for date field.
It would be a lot easier to use a different set of API calls to do this, you can avoid having to manipulate the database directly:

// Extract the first field item
$date_items = field_get_items('node', $node, 'field_date_start_rent');
$date_item = array_shift($date_items);

// Get the field value
$start_rent = $date_item['value'];

// Update the other field
$node-&gt;field_cubagan[$node-&gt;language][0]['value'] = $start_rent;

// Save the node
node_save($node);


Just as an aside: you're not making the best use of the DB API at the moment, you should be using placeholders and provide arguments to db_query() rather than interpolating them directly into the query string. The equivalent of your SELECT statement written the recommended way would be:

$args = array(':nid' =&gt; $node-&gt;nid);
$sql = 'SELECT field_date_start_rent_value FROM {field_data_field_date_start_rent} WHERE entity_id = :nid';
$startrent = db_query($sql, $args)-&gt;fetchField();