0
votes

I just started maintaining a pretty large Drupal website. The site has a playlist that lists songs. The content type for each song has a text field where the user types in the time the song was played. Yes, its a TEXT field, not a date field :( So by default in Views I have no way of exposing a filter with a BETWEEN operator. Ugh.

Is there any way I could possible convert this field to a date field so I can use the between operator? Or maybe there's some other work-around I could do? Thanks for any help.

1

1 Answers

0
votes

Your best bet is to use a custom module that stores that value in an actual Drupal date field when the node is saved/loaded.

function mymodule_node_presave($node) {
  if ($node->type == 'whatever_content_type') {
    $node->actualdatefield[LANGUAGE_NONE][0]['value'] = date('Y-m-d g:i:s', strtotime($node->userdatefield[LANGUAGE_NONE][0]['value']));
  }
}

Something like that. You'd want to fire off one of the update options that triggers a node_save event through the content listing page, like publish nodes, to update existing nodes.