I'm trying to migrate some data from a csv to a field_collection in a user profile. Everythings works fine but not for a field of Date (with range) type.

I'm on Drupal 7.22 and I'm using Migration and Migration Extra modules

I do not receive any error message, but the data is not entered, please help me

My code in the migration class:

$source_file = drupal_get_path('module', 'module_name') . '/data/user_employments_info.csv';

$columns = array(
  array('employment_period_start', 'employment_period_start'),
  array('employment_period_end', 'employment_period_end'),

$this->destination = new MigrateDestinationFieldCollection(
  array('host_entity_type' => 'user')


$this->addFieldMapping('host_entity_id', 'user')->sourceMigration('User');


$this->addFieldMapping('field_usr_bkg_emplo_time', 'employment_period_start');
$this->addFieldMapping('field_usr_bkg_emplo_time:to', 'employment_period_end');
  • Probably a format issue? Have you checked what the format looks like before it gets passed to the fieldMapping? Probably you need to format it in a prepareRow() function? – Lance Aug 7 '13 at 13:30
  • I thought about it in fact I saved data with the simple form and I used the same format (YYYY-MM-DD 00:00:00): a common datetime without tracking hours, minutes and seconds. I used the format also literally in the code but I get the same result: nothing. If I'm omitting something I'm sorry but I'm not an expert in Drupal – vincenzodb Aug 7 '13 at 13:34
  • Probably this helps you? drupal.stackexchange.com/questions/56762/… – Lance Aug 7 '13 at 13:38

At the base there was a problem: the module dates was patched. The final code that have worked:


dependencies[] = migrate
dependencies[] = migrate_extras
dependencies[] = date
dependencies[] = date_migrate


projects[migrate][subdir] = "contrib"
projects[migrate][version] = "2.6-rc1"
projects[migrate_extras][subdir] = "contrib" 
projects[migrate_extras][version] = "2.5"
projects[date][subdir] = "contrib"
projects[date][version] = "2.6"
projects[date][patch][] = "https://drupal.org/files/date-consolidated_migrate-1.patch"


$this->addFieldMapping('field_date', 'date_from');
$this->addFieldMapping('field_date:to', 'date_to');
$this->addFieldMapping('field_date:timezone', 'UTC');

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.