We have a content type basic page that has a Date field (field_bp_date). We want to use the hook_update to delete all data in this field. We are having trouble figuring out what is the best way to simply delete all data in the field_bp_date field on the basic page content type?

Ideally we would like to do the following:

function mymodule_update_7001(...) {
    $content_type = 'page';
    $fieldDataToDel = 'field_bp_date';

    //some function/hook to delete all the data

2 Answers 2


If you only need to do this once you could use Views Bulk Operations https://www.drupal.org/project/views_bulk_operations


  1. Click "Add new view" link
  2. Show "Content" of type "YOUR_CONTENT_TYPE"
  3. Click "Continue & Edit" button

Under the FORMAT section change Show: click 'Content' change to 'Fields'

  1. Click 'Apply' button
  2. Click 'Apply' button again

Under FIELDS section click the 'Add' button

  1. Checkmark 'Bulk operations: Content'
  2. Under SELECTED BULK OPERATIONS choose 'Modify entity values' checkbox
  3. Scroll down a little, you will see OPERATION SETTINGS choose that date Field you want to edit.
  4. Click 'Apply' button
  5. Click 'Save' to save that View

Go to the View Page you just created.

  1. Under Operations choose 'Modify entity values'
  2. Select one or all of them (I suggest you do one as a test).
  3. Click the 'Execute' button. This page will allow you to set the Date to anything you want, even nothing. TIP! for Date if you want no date you need to change all values to blank. You can't delete just the hours, you need to set all of them to blank, which gives you the result you requested.
  4. Click the 'Next' button.
  5. Click the 'Confirm' Button.

Congrats. Go back and run it on all of them, if it went as expected on the one test node.

  • How to do so ?? Commented Jun 2, 2016 at 19:11
  • It is a GUI interface. Create a View. Add a "Bulk operations" field if available (see technical details below). Configure the field. There's a "Views Bulk Operations" fieldset where the actions visible to the user are selected. Go to the View page. VBO functionality should be present. drupal.org/node/1591352 Commented Jun 2, 2016 at 19:17
  • Please transform your comment in an updated version of your answer (which is where it really belongs). Just trying to get you going on this site, ok? Commented Jun 2, 2016 at 19:19
  • You should also explain how via VBO those data to be deleted can actually be deleted. EG which VBO "action" to use for doing so ... Commented Jun 2, 2016 at 19:21
  • There. I wrote a whole tutorial. Commented Jun 2, 2016 at 20:02

You can just run a mysql delete command. As this is a date field, there aren't any dependencies on other tables.

function mymodule_update_7001() {
  db_query("DELETE FROM field_data_field_bp_date WHERE entity_type = 'node' and bundle = 'page'");
  db_query("DELETE FROM field_revision_field_bp_date WHERE entity_type = 'node' and bundle = 'page'");

Note: You would only want to use this approach if you felt certain that there weren't any other modules that needed to react to that data.

  • True, you "can", but I'd not recommend doing so. Any idea what the problem with such approach really is? Commented Jun 2, 2016 at 19:23
  • No, what are you hinting at?
    – oknate
    Commented Jun 2, 2016 at 19:25
  • Using this approach, do you allow Drupal core and/or other modules to detect that change (and trigger whatever related actions)? That's why I rather prefer an approach similar to drupal.stackexchange.com/questions/189450/… Commented Jun 2, 2016 at 19:35
  • Yes, you would only want to use this approach if you felt certain that there weren't any other modules that needed to react to that data.
    – oknate
    Commented Jun 2, 2016 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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