0

I have a csv with a Date field that contains the date in one of the following formats:

  • dd/mm/yy (ex. 13/11/04)
  • dd/mm/yyyy (ex. 13/11/2004)

I need to import these dates to my field in the format dd-mm-yyyy, using feeds.

I've tried everything but without success. I have my date field set with my custom date format (dd-mm-yyyy).

What do I need to do in feeds (or even feeds tamper) to import this data?

Thanks.

4 Answers 4

1

I've struggled with this question today, and because i didn't found any clear answer here's the method with drupal 8.7:

  • go to your node type structure, and select the display of your field (for example : DD-MM-YYYY)
  • go back to the feeds mapping, remove your date entry.
  • add a new entry for the date, or rebuild the entire mapping if you can't change the order of your csv.
  • clear the cache
  • the date work now with your new format
1

Here's a working csv to import into date field via feeds :

"guid","title","created","end","datetime_start","datetime_end","year",
1,"Lorem ipsum",1251936720,1351936720,"1955-11-05 12:00","1955-11-05 15:00",1955
2,"Ut wisi enim ad minim veniam",1251932360,1351932360,"21-10-2015 23:29","22-10-2015 2:29",2015
3,"Nam liber tempor",1190835120,1390835120,"2018-02-09T00:00:00.0000000Z","2018-02-10T22:00:00.0000000Z",2018
4,"Eodem modo typi",abc,def,"08-14-2012","08-15-2012"

Find more working examples into /modules/contrib/feeds/tests/resources/csv/

0

The date itself typically is stored in the mysql database as a timestamp or datetime format, depending on the configuration when you setup the field.

To ensure the Feeds' built-in date mapper importer processes the dates properly, I recommend:

  1. open the CSV as a spreadsheet
  2. reformat the date column to be an integer timestamp field
  3. Resaved the csv with the numeric value for the date rather than the formatted value.
  4. Update your feed importer mapping for the revised date field/column data from the CSV.
  5. Run the import.

Alternatively, the Feeds Tamper module may be used to parse the date parts from a string formatted date in your Csv, and then join them as needed into a properly formatted date entry; but it would still require a consistent format in the csv. (you need either two or four-digit years in all the dates)

1
  • I don't have write access to the csv (I'm importing externally). Anyway, I solved my problem with Feeds Tamper and the PHP plugin. I know it's not the cleaner solution but it was the only one that solved my problem.
    – zephirus
    Commented Aug 29, 2018 at 14:18
0

Goussing is right, this ansewr is based on his (i upvoted his answer), i did this on D7, steps:

1.- convert your date to unix (https://www.extendoffice.com/documents/excel/2473-excel-timestamp-to-date.html), (i did this in libreoffice, same thing) this way no matter wich language is your drupal site and date formatting.

2.- go to your node display settings, select your date field (my case a field collection field), select custom and in format enter U (for unix).

3.- important! as Goussin sugests, delete this field mapping and re-enter it again, dont mind of CVS order in columns.

4.- clerar caches

5.- do your import by feeds.

6.- change your field display as desired. done.

enter image description here

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.