Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, firstly thanks for this great module! I have come with feeds importer issue though:)
Steps to reproduce
- Create a date field 'Year' for node - article. This field only collects year and only have one value. So, when create new article, only need to type year, e.g., 2015 for date field.
- Create new importer to import node - article. This importer uses stand along form and has "Year:Start" as mapping target.
- Create a csv, and year's value in csv could like '2017', '2017'.
- Import this csv with that importer to create node - article. All the year field get value '2013'(Current time), Values for year field from csv have been ingored!
This is the field data structure before node is saved.
Any help will be appreciate. Thanks!
Comment | File | Size | Author |
---|---|---|---|
date_field_feeds.jpg | 59.36 KB | smiletrl |
Comments
Comment #1
smiletrl CreditAttribution: smiletrl commentedOk, problem fixed.
date format in csv, it should look like '12/4/2013'
Comment #3
MsG CreditAttribution: MsG commentedI have the same problem. I don't understand your solution. Can you explain it any further?
I have the date format as 2012 in my CSV file.
When I manually insert a year in my user node it does work.
Comment #4
vijaycs85@MsG, as per @smiletrl in #1 you need to configure field to accept just year, but the CSV should have 01/01/2012 format instead of just 2012
Comment #5
capfive CreditAttribution: capfive commentedIs there a possibility that feeds tamper can be used to fix this? I have a client with 40,000 plus entries and the data comes in like this, so I hope there is a solution that doesn't require changing the data in the spreadsheet?
Comment #6
capfive CreditAttribution: capfive commentedOK! i found the solution to why you are having your issue smiletrl.
First of all, what is happening is the dates are being see as a time (e.g 2017 = 20:17 or 8:17pm) so the only way to fix this is to add the date to the start, so you need to have jan 1, 2017 (as vijaycs85 stated)
This for me doesn't work, there was no way i was going to convert all my data, so I did some digging and I found a solution!
First you will need to install the following modules:
What this will allow us to do is inject some PHP to add some text before the date field so it will be read correctly by the system.
open the feeds tamper area and and add some php code that looks like this
return !empty($field) ? strtotime("Jan 1, ". $field) : NULL;
I have tested this and it gave me the desired outcome that you were after :) happy Drupaling!
Comment #7
smartsystems160 CreditAttribution: smartsystems160 commented#6 did not work for me (Using Date 2.9). I resolved this by changing the formatter of the date field from "date and time" to "plain" in the source feeds (i am using views data export. Make sure the source content type and the destination content type date configurations are same