Comments

infojunkie’s picture

Subscribe.

petey318’s picture

Subscribing. date just went to 6.x-2.0 so its looking reasonably stable now...

Robrecht Jacques’s picture

Could you try date.inc from CVS? Copy the file into sites/all/modules/node_import/supported/date/date.inc (creating a new directory).

If you could give me feedback on how it works or when it doesn't I'll be able to fix those and include CCK Date into -rc5.

Thanks.

infojunkie’s picture

FileSize
422 bytes

I tried to import the attached file. In Set import options (step 5 of 8), I chose "Custom Format" and "m/d/Y". On the preview screen, I got "An illegal choice has been detected. Please contact the site administrator." for each previewed record, as well as a var_dump of the values array. When I remove the date from the fields to be imported, the import proceeds correctly.

In the var_dump(), I noticed that field_date is set to be

[field_date] => Array
        (
            [0] => Array
                (
                    [value] => 2008-09-15T00:00:00
                )
        )

whereas when I create a new node from the UI, the value that goes in for the same field is

[field_date] => Array
        (
            [0] => Array
                (
                   [value] => 1241161200
                   [value2] => 1236028220
                   [timezone] => America/Vancouver
                   [offset] => -25200
                   [offset2] => -28800
                )
         )

The field_date I'm using is of type datestamp.

Thanks for your help!

infojunkie’s picture

Here's some code for date.inc that seems to work in the case of date fields of type 'date' and of widget type 'date_select':

<?php
function date_node_import_values_alter(&$values, $type, $defaults, $options, $fields, $preview) {
  foreach (node_import_cck_fields($type, 'date') as $fieldname => $fieldinfo) {
    $cck_fieldname = node_import_cck_name($fieldname, 'value');
    switch ($fieldinfo['widget']['type']) {
      case 'date_select':
        foreach ($values[$fieldname] as $i => $value) {
          $values[$fieldname][$i]['value'] = date_convert($values[$fieldname][$i]['value'], $fields[$cck_fieldname]['input_format'], DATE_ARRAY);
        }
        break;
    } 
  } 
}
?>

When I added this code to date.inc, the imported worked without complaining. Note that the date_convert() function takes a timezone argument that I left as default for the time being. I'll be working on other widget types and other date types.

infojunkie’s picture

Status: Active » Needs review
FileSize
2.15 KB

Attached is a new version of date.inc that I verified to work with all CCK Date types, widget types, and also with 'To date' enabled. Whoever is interested please test it and send your feedback here. Thanks!

Robrecht Jacques’s picture

Nice work. After some reviewing I'll include it in -rc5.

A question:

          $fields[$cck_fieldname]['date_format'] = $fieldinfo['widget']['type'] == 'date_select' ? DATE_ARRAY : DATE_ISO;
          $fields[$cck_fieldname]['output_format'] = DATE_ISO;

Could you not set output_format to DATE_ARRAY or DATE_ISO? Then you can get rid of hook_node_import_values_alter() altogether. Or am I confused about date_format and output_format myself :-)

infojunkie’s picture

I tried to set output_format directly to DATE_ARRAY and avoid the extra conversion but got the following behaviour:
* warning that mb_strlen (inside drupal_strlen) is passed an array on line 602 of node_import.inc. I commented that line just to let the processing continue.
* the DATE_ARRAY values end up in values[cck:field_date:value] but *not* in values[field_date] which is what is desired. I did not further debug the issue.

Also, I made the following change to case 'value2': in date_node_import_fields():

$fields[$cck_fieldname]['is_required'] = $fieldinfo['required'] && ($fieldinfo['todate'] == 'required');

since the 'To date' should probably not be required if the field as a whole is not required.

jmbeach’s picture

I've been testing out the ability to import Date fields with Node Import and been successful using the date.inc that was posted in #6 above.

However, if the date field for my content type has the repeat options enabled, I get a white screen with "Fatal error: Cannot unset string offsets". This error points to /sites/all/modules/date/date_repeat/date_repeat_form.inc on line 212.

When I am setting up the import, on step for for my field, called "Event date", there is an entry for "Unsupported: Event date -rrule". I assume that this means that importing repeat options is currently unsupported in the Node Import module.

If I set up my date field without repeat option, I am able to successfully import a CSV of dated nodes into my installation.

This has been reported over on the Date modules issue queue as http://drupal.org/node/379102 by someone else, but I thought I would mention this over here, too.

infojunkie’s picture

I hadn't tested the repeat option :-) I'll try it and report my progress here. Thanks for testing!

presleyd’s picture

I'm getting the following error

    * warning: Invalid argument supplied for foreach() in /var/www/html/sites/all/modules/date/date/date_elements.inc on line 409.
    * There are errors in Project date:
          o Some value must be entered in the To date.
          o The To date must be greater than the From date.

This date field and it's corresponding To date is required. If I make them both optional the message about 'Some value myst be entered in the To date.' goes away but the message about To needing to be greater than From and the foreach warning continue. Any ideas?

I have tried both the 2.0 and the dev versions of date with no difference.

infojunkie’s picture

@presleyd: Did you specify multiple values for your date field? When I did so in mine it gave me those errors.

presleyd’s picture

Started over with reloading the csv file and recreated the Date field and that seemed to do it. I don't think that field ever had multiple values defined though so not sure what was causing the problem. I did switch from the JS popup tool to just a simple select widget though, maybe related?

infojunkie’s picture

@presleyd: I had tested against the JS popup date widget so it's less likely to be the cause. I'm still working on the multiple values issue.

@jmbeach: the date repeat feature uses a multiple values date field, which currently doesn't work. So I'll fix that first.

jmbeach’s picture

@kratib: It would be nice if it could just drop a NULL into the rrule field for now. My date field has the repeat options enabled for events that I hand-enter, but the datasets I'm trying to import are strictly single occurrence dates.

catch’s picture

Tested this (no multiple or repeating dates though), and it worked great for me.

infojunkie’s picture

@jmbeach: Even if your dates are single-valued when you import them, the fact that they have the repeat option turned on makes them automatically multi-valued internally, and hence subject to the problem of multi-valued dates in general. I did try to set the rrule field to NULL but got the same erroneous behaviour.

infojunkie’s picture

Assigned: infojunkie » Unassigned

I've tried to debug through the date module to find the source of this error but I was unable to find it so far. I won't be able to put more time into this for now.

The state so far is that the latest date.inc file contained in this thread seems to work for single-valued date fields, but not for multiple values nor for repeat dates. Sorry everyone!

Robrecht Jacques’s picture

Status: Needs review » Needs work

#6 has been committed to CVS (together with small fix in #8).

Patch needs more work.

thtas’s picture

I'm just trying out the latest date.inc

It looks like it's working well for me but i notice it's not automatically selecting the field in my CSV on step 4

my CSV field is called "DATE OF ISSUE", and my date field is called "Date of Issue/date_of_issue" but it's not automatically selected on step 4 of the wizard like title and other fields i have (simple text).

Great module though :)

presleyd’s picture

@kratib

I have to confirm my problems sure seem related to the date popup widget, I get this error whenever that is enabled and never with select list ceteris paribus.

martysteer’s picture

I can confirm this causal relation too.

Just for the import I changed the widget to 'select list', then switched back after import.

infojunkie’s picture

Thanks everyone for this report. I was able to reproduce this behaviour. I'll look at it during this coming week.

vinothg’s picture

Assigned: Unassigned » vinothg
Category: feature » support
Priority: Normal » Minor
Status: Needs work » Reviewed & tested by the community

Great Work!

Comment #6 patch worked without any issues for me!

Coupon Code Swap’s picture

I am using the latest dev version of Node Import and the latest dev version of CCK Date and I am not able to get the date import working. Keep getting an error that "The dates are invalid".

    [cck:field_expires:value] => Array
        (
            [0] => 2009-05-16T00:00:00
        )
petey318’s picture

@undoIT -

I had the same issue last night - took me a while to get to work - but my problem was the "select list" issue reported in #21 and #22. The import only worked for me when I had the date widget in my CCK content type set up as a "select list". It steadfastly refuses to work when you have it set to be a text field.

The other thing is to make sure that your import format matches the format of the data in your CSV file. You might need to select a "custom format" in one of the final steps of the import process, and then set that to match your CSV data.

Coupon Code Swap’s picture

Thanks, changing the date widget to Select List did the trick. Also, had to change taxonomy vocab to Tags to get term import working. No more errors :)

rbishop’s picture

ive tried this as listed above but still a few days of head-scratching , is the recommend type "date" or "datestamp" ?
what have others that got this to work doing for timezone ? i cant tell if that is my problem. ive tried many combinations

i keep getting this error "warning: date_timezone_set() expects parameter 1 to be DateTime, null given in [...]/drupal_6_10/sites/all/modules/date/date/date_elements.inc on line 229."

ive tried CSV with these options,

"2005-11-16 12:00:00";
"2005-11-16";

maybe i need to try 12/12/2009 like others list here

zw111aaa’s picture

to #6, kratib
Thank you for your help.

but there is a waring like this.
warning: date_offset_get() expects parameter 1 to be DateTime, null given in C:\xampp\htdocs\sites\all\modules\date\date\date_elements.inc on line 500.

so I have to make a small modify in the file(/sites/all/modules/date/date/date_elements.inc).

line 467
// add by zw111aaa start
if (isset($element[$from_field]['#value']) && !is_array($element[$from_field]['#value'])) {
$element[$from_field]['#value'] = date($element[$from_field]['#date_format'],strtotime($element[$from_field]['#value']));
$element[$from_field]['#value'] = array('date' => $element[$from_field]['#value']);
}
// add by zw111aaa end

I think it is not a good way,it is just no warning.
If you have a good way to modify this warning,please tell me.

Thank you very much, kratib.

frostystoo’s picture

I too have the problem of date repeat making the import not work. When I change the datetime field type to a select list, the dates don't get entered at all and the forms do not work so doesn't seem to be an option.

davidmolliere’s picture

Comment #6 patch worked without any issues for me too :)

Kudos for this module, the ability to import Dates is a real plus !

sagrotan’s picture

Same here as #28

Hav' tested a lot, but no clue, also with the latest snaps of node_import and date. Sadly, i am not able to get in the drupal code yet.

Help really appreciated...

Pol’s picture

FileSize
58.88 KB
48.71 KB
22.85 KB

Same problem for me... using dev version of today of node_import.

I've attached the screenshots...

The date field is a text field... What to do to get it working ?

Thanks !

sagrotan’s picture

@pol:

try to switch to "select list" in date field properties like #27 and do it again

seaneffel’s picture

I'm working with the most up-to-date dev releases of both Date and Node_Import and I can't get date values to import at all. Here is my problem description:

1. I create a CSV file where each row looks like this:


"Some Node Title","2009-02-19 18:00"

2. My Date field is a date (not datestamp) "select list" with a prefab format that looks like "2009-04-23 18:22". The to-date is optional.

3. I'm not using repeating dates or popup widgets or anything. It's just a straight up, normal field containing a Date_module value.

4. I start the node import process. I upload the file and map the values into the Title field and the Date field. After mapping I am presented with the date format choices in step 5 of the import process and I choose the date format that matches the both the values I suggested above ( which is, again, "2009-04-23 18:00"). I set my timezone for New York.

5. When I get to step 7, I get an error, "An illegal choice has been detected. Please contact the site administrator." I can't figure out why I'm getting this. The scheme dump beneath the error messages says:


Record 1:
An illegal choice has been detected. Please contact the site administrator.
values = Array
(
    [created] => 
    [node_import_build_mode] => 1
    [title] => Videoblogging Production
    [cck:field_date_range:value2] => 
    [cck:field_imagefield:list] => Array
        (
            [0] => 1
        )

    [cck:field_date_range:value] => Array
        (
            [0] => 2009-02-19 18:00
        )

    [og_groups] => Array
        (
        )

    [cck:field_imagefield:data] => 
    [cck:field_cost:value] => 
    [type] => date
    [body] => 
    [format] => 3
    [cck:field_imagefield:fid] => 
    [revision] => 0
    [uid] => 446
    [log] => Imported with node_import.
    [promote] => 0
    [status] => 1
    [sticky] => 0
    [path] => 
    [comment] => 0
    [name] => shaun
    [taxonomy] => Array
        (
            [11] => Array
                (
                )

            [9] => Array
                (
                )

        )

    [field_date_range] => Array
        (
            [0] => Array
                (
                    [value] => Array
                        (
                            [second] => 0
                            [minute] => 0
                            [hour] => 18
                            [day] => 19
                            [wday] => 4
                            [month] => 2
                            [year] => 2009
                            [yday] => 49
                            [weekday] => Thursday
                            [month_name] => February
                            [0] => 1235066400
                        )

                    [value2] => 
                )

        )

    [field_imagefield] => Array
        (
            [0] => Array
                (
                    [fid] => 
                    [list] => 1
                    [data] => 
                )

        )

    [field_cost] => Array
        (
        )

    [op] => Preview
)

6. When I do not include the date field value in the import then everything goes smoothly. When I attempt to fill in the to-date value with something, I get the "Illegal Choice" error twice.

7. I take a chance and try to import the date values as a custom format in step 5, by selecting "custom format" and entering "Y-m-d h:i" and I get the same results ("Illegal Choice").

Hopefully this is enough of a write up that someone can figure out what am I doing wrong? Is it me or is there a bug out there that I can't see? Thanks for the help.

notebene’s picture

I'm unfortunately failing heinously with this, considering just entering the 200+ records by hand.

Seems like this should be simple.

I'm using the latest DEV. I replaced my /sites/all/modules/node_import/supported/date/date.inc with the one up on #6 (I assume that's the right place).

Got my CSV file, my dates are formatted as mm/dd/yyyy (but not necessarily leading 0s), so I selected a 'custom' form in step 5 and used 'n/j/Y' as my custom format, and by the time I get to step 7, I get:

There are errors in Term Date:
  The dates are invalid.

...

    [cck:field_termdate:value] => Array
        (
            [0] => 2006-10-07T00:00:00
        )

Thoughts? Ideas? Suggestions?

Edit: Nevermind, didn't read everything above, I'm seeing something that might be my issue.

Update 2: Yeah, that was it, the popup date widget. Hopefully this gets logged as an issue to still resolve. I would like to be able to enable this so some power users can upload data, but if the only solution for dates is to let them go change the date picker from the popup on the content type before/after the import, that's not a very good solution. I could leave the date input as the select, but in all the years I've been doing this, 'everyone' wants the cute date picker and throws a fit when they see a date field without it, and I don't blame them.

seaneffel’s picture

Category: support » bug
Priority: Minor » Normal
Status: Reviewed & tested by the community » Active

Refocusing this issue with updated reports on the bug at hand.

Importing records into nodes that have dates tend to fail because of several reasons, including both the date field widget setting and the formatting of the date value itself.

The solution might be to talk to KarenS about how to make her Date module more accessible to Node_import.

seaneffel’s picture

Title: CCK Date module » Can't import date values into Date module fields

Better name to suit this issue, too.

Aren Cambre’s picture

subscribe

KarenS’s picture

I don't have time to do much on this, but wanted to post a suggestion. I'm not sure how node_import works, but I assume from the problems you're having you are using drupal_execute() somewhere. I always recommend using node_save() instead of drupal_execute() because drupal_execute() is horribly fragile and breakable (and there are known bugs). Even Jeff Eaton (one of its creators) suggests avoiding it. I did a whole long thread on all the problems it creates when trying to fix brokenness in Content Copy (which was using drupal_execute()).

If you use drupal_execute() you have to format the data in ways that are very specific to the widget the field is using, and even then you'll have all kinds of problems because drupal_execute() validation fails if you try to do it more than once in the same session (it's a known core bug that has a looonnnggg thread) and anything that should happen during validation will fail. And the date module does work to re-factor the widget values into the right format for the field during validation, so things will break if that doesn't get triggered.

If you use node_save() you don't need to know anything about the widgets, you just import data in the format the field expects -- YYYY-MM-DD HH:MM:SS for datetime, YYYY-MM-DDTHH:MM:SS for ISO and 9999999999 for Unix. Super super simple.

The only reason for using drupal_execute is for validation, and the validation doesn't work anyway.

rkdesantos’s picture

Using the patch in #6 with the latest -dev for both the Node Import and Date modules and this got me most of the way there but two problems still occur:

I get the following error in step #7: "The date is invalid" (triggered by the check in line ~480 in date_elements.inc in the date module). My data is formatted thusly: 20090510 for which I set a custom format of "Ymd". The field is set to not have a "To Date" and allow blanks.

If I comment out that error I can thru the import but no date is actually saved into the new node and no further errors are generated. The previews all look correct and nothing obvious is wrong at that point but nothing is stored.

xamanu’s picture

subscribe

jakew’s picture

subscribe

JoshG’s picture

FileSize
837 bytes

I was running into a problem importing dates with times like 14:00. The date module (6.x-2.1) was barfing when asked to use minutes with a value of zero: the hours minutes and seconds are not properly zero-padded. The attached patch takes care of this.

hotspoons’s picture

I've been struggling with this a lot today, trying to import around 15,000 (!) relational records from different tables exported to CSV files. The first issue I had was listed above, as something along the lines of "date_offset_get() expects parameter 1 to be DateTime, null given in /var/www/sites/default/modules/custom/date/date/date_elements.inc on line 500.". Setting the CCK field to a select list, as has been mentioned elsewhere in this bug report, fixed that issue.

The next issue was I kept getting the "An illegal choice has been detected. Please contact the site administrator." and a var_export of the node objects on the preview for the dates, on some, but not all of my dates. I finally figured out what was causing that - some of my records go back as far as 2001, and the CCK date field defaults to "-3/+3" as the years back and forward to select from. So setting the min/max years for the records to -10/+10 on the CCK date field fixed that issue.

I'm still in the process of importing several hundred event records from 2001 through now (where I got stuck on the dates). After that, I have about 13,000 image nodes to import that will combine into galleries for each event that will be glued together with Taxonomy that will have to be hand built using a SQL query and the event ID imported to a temporary CCK field. But anyhow this particular bug report has been my saving grace trying to get everything imported to the system thus far. Thanks,

-Rich

hotspoons’s picture

FileSize
78.84 KB

Scratch that. It was 33,410 image nodes that needed importing. And since node import doesn't support file or image attachments to nodes *but* it does support CCK files and images, I came up with a work around.

Attached is my import, 14 hours in. I wrote up in detail how to import image attachments for nodes (and presumably file attachments for nodes should work as well) using a small bit of SQL and CCK fields as an intermediary here: http://drupal.org/node/483248

OneTallShort’s picture

Just want to confirm that the 2009-04-22 dev version of node-import still doesn't handle date fields with "Text field with custom input format". You MUST use "Select List" as your date widget. Otherwise, you will get a "The dates are invalid" on the first date it finds.

Note also that the "The dates are invalid" message only shows once (on the first date it tries to import), even though you may have multiple problematic date fields using the text widget.

It would be nice if this problem was at least noted in the support docs....

Aren Cambre’s picture

Priority: Normal » Critical

(Canceling this comment. Missed the fact that you have to use the latest -dev release, not RC4.)

Aren Cambre’s picture

Priority: Critical » Normal

(Restoring priority to how it was before I messed with this issue.)

Aren Cambre’s picture

Look at #444884: Integration with nodereference fields only works if nodereference field set to "select" widget. The solution is the same: use a select field. Could this problem be unrelated to the Date module?

Cyberwolf’s picture

Subscribing.

djflux’s picture

subscribing

Junro’s picture

subscribe...

GuyPaddock’s picture

FileSize
5.63 KB

Can you guys try replacing node_import/supported/date/date.inc with the attached file and importing with your date pop-up fields? I added the different cases for the different kinds of widgets -- the Date module actually has at least 3 different ways of arranging the field value depending on the type of widget and chosen format, but I think I have a nice generic solution for all three.

GuyPaddock’s picture

FileSize
6.57 KB

Attached is an even more improved version which corrects an issue with AM/PM being in the wrong case, and the default values not working when the value being imported was empty (used to default to January 1, 2009).

I hope it helps!

alex.k’s picture

FileSize
7.7 KB

This file worked well, thanks very much. I had to add a section handling timezones, attaching the file with this change.

[EDIT] one thing that this file doesn't do very well is adapt to the chosen input format. It essentially depends on dates being entered as "[date] - [time]", as it looks for space-dash-space to split the time and date portion.

robomalo’s picture

subscribing

alex.k’s picture

@robomalo could you try the attached file, and report if it worked for you? If not, then add what your date field configuration and widget was. It would help the maintainer to know if the file works. Thanks.

robomalo’s picture

The file doesn't seem to be working properly for me.

The following widgets had the following errors:

select: "An illegal choice has been detected. Please contact the site administrator."
text field: the right month and days, but the wrong year
text field + popup: the right month and days, but the wrong year

I tried Y-m-d H:i and a custom format Y-m-d. Both fail. I made sure my CCK field input format matched the import settings in each attempt.

I also tried it with the "-" between the date and time...

robomalo’s picture

I did just discovered it breaks my dates before 1900. strtotime() doesn't support this and is used by this .inc. Correct me if I am wrong, but I _think_ Date 2 supports older dates. Therefore, I think this file will have to be altered to support Date 2's functionality.

robomalo’s picture

In the supplied date.inc I changed line 113 from

$values[$fieldname][$i][$colname]['date'] = date($widgetFormat, $time);

to

$values[$fieldname][$i][$colname]['date'] = $value[$colname];

and it worked for me. I know this won't work for everyone and only applies to a small group of people. This just shows
that the line

$time = strtotime($value[$colname]);

is the source of my errors. I had to make sure my CSV date Y-m-d matched the input format of my content type Y-m-d.

legion80’s picture

I am in a similar situation to robomalo in that I have historical dates I'm dealing with. I used the code in #56 with the hotfix in #61, but at step 7 I am getting errors of "A valid date is required for Dates of existence 2 From date. Dates of existence 2 To date is invalid." I tried to import with date fields of type Datetime and Date.

An excerpt of the output of the record preview:

values = Array
(
    [created] => 
    [node_import_build_mode] => 1
    [title] => ant
    [cck:field_existence_dates:value] => Array
        (
            [0] => 1170-01-01
        )

    [cck:field_existence_dates:value2] => Array
        (
            [0] => 1230-01-01
        )
    [revision] => 0
    [uid] => 1
    [log] => Imported with node_import.
    [promote] => 1
    [sticky] => 0
    [status] => 1
    [comment] => 0
    [name] => admin
    [taxonomy] => Array
        (
        )
    [field_existence_dates] => Array
        (
            [0] => Array
                (
                    [value] => Array
                        (
                            [date] => 1170-01-01
                        )
                    [value2] => Array
                        (
                            [date] => 1230-01-01
                        )
                )
        )
    [op] => Preview
)

I am trying to figure out what part of node_import_check_date() is failing, but am unsure how to get debug messages injected in the output. The csv import only had date info (Y-m-d). Any suggestions what might be happening?

hotspoons’s picture

I ran into this a couple of days ago - what you need to do is configure the CCK date field you are trying to import the date to, and change the granularity to Year, Month, and Day.

FiNeX’s picture

The field on the CSV is something like "2007-01-29" (Y-d-m) and the granularity of the cck field is Year, month and day but it still fails.
I still have the "illegal choice" error message.

any suggestion?

legion80’s picture

I did a double-check and the granularity was already set to year, month, and day.

My field has an optional to-date.

BassPlaya’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc4

hotspoons, did this really work for you? Not for me. Using the latest date.module, node-import module + advanced help.
I've reset my dates to granularity to year month day and apparently you can't select a timezone. So no timezone. Tried to import but that still failed.
If you have further info that I'm not using rite now, please let us know.
Thanx.

legion80’s picture

ok i think i finally figured out what's going on, but am unsure about where the code needs to be altered.

after a lot of dsm()... it looks like what was going on was my data in the csv was formatted as "Y-m-d" but the field itself has a required format of "m/d/Y".

i was able to determine this by looking at date_text_input_value() in date_api_elements.inc. there's a line that says:

$value = date_limit_value(date_convert_from_custom($input, $element['#date_format']), $granularity);

the #date_format attribute is set to the node's format, not the csv file's specified format.

i am going to re-format those fields in my csv and try re-importing again and see if that fixes the issue.

aterchin’s picture

#55 worked for me: date set to jquery popup calendar, 8/1/2009, m/d/Y custom format on import, no timezone conversion.

funkeyrandy’s picture

i cant get any situation to work...my csv has format of 08/2009..ive tried all scenarios and patches...illegal choice!..added timezone/removed to no avail.

can some kind soul help here..ive been up for 15 hrs on this!

alex.k’s picture

Could you not use a normal dd/mm/yyyy format, and after importing, if you don't need the day of month, remove it from granularity and/or display formats?

funkeyrandy’s picture

thing is, ive already done that!

alex.k’s picture

Importing csv formatted as yyyy/mm/dd into a datestamp field that uses minical popup widget worked for me using the patch in #56. Granularity down to the minute, and TZ handling set to 'Date's timezone'. Used the latest DateAPI and latest -dev version of node_import.

funkeyrandy’s picture

is a datestamo field different from a regular date field?..just making sure

alex.k’s picture

It's stored in the database differently, but to the user there's no difference IIRC. Please check date api docs, though.

funkeyrandy’s picture

did exact same thing, tz on field set to date, tx on import set to newyork...used datestamp as well

i get this:
There are errors in Article Pub Date:

* The dates are invalid.
thanks for helping with this..i hope i resolve it !

r

funkeyrandy’s picture

not sure if this will help, but the out put is like this in the error:

[field_pubdate] => Array
(
[0] => Array
(
[value] => 2009-06-01T00:00:00
[timezone] =>
[offset] =>
)

)

funkeyrandy’s picture

could this be part of the issue?

[value] => 2009-06-01T00:00:00

funkeyrandy’s picture

ok this is horrible....ive just spent 15 hrs triyng to import a date field that should work out of the box with a bare bones drupal install...latest versions of node import and date....and ive developed over 20 drupal sites. can anyone help? i need to launch another site tonight...see my prev. posts...ive literally tried everything...even formatting my csv like this: 2009-06-01T00:00:00

all i get is The dates are invalid.

funkeyrandy’s picture

ok i have a temp fix for anyone with this issue: use date 6.x-2.0

it worked no problem with patch #56

r

jameswoods’s picture

I hate to sound like another "me too" but...

I'm running Acquia Drupal on a Windows local dev box (hmmmm could this be it?)
I attached the "a Node import debug report"
I have the date.inc file from #56 put into l\sites\all\modules\node_import\supported\date
The node cck field is: Date, select list, custom imput format: n/j/Y, to date: never, granularity: year month day

I get these errors on step 7
# warning: mb_strlen() expects parameter 1 to be string, array given in C:\Documents and Settings\guru\Sites\acquia-drupal-site\acquia-drupal\includes\unicode.inc on line 404.
# An illegal choice has been detected. Please contact the site administrator.

And of course no nodes import 8^(

Any thoughts?

ADDITIONAL INFO:

When I remove the date from the import, everything imports fine, but the date field in question gets populated with 1/1/2009 (must be a default value of sorts)

ADDITIONAL ADDITIONAL INFO:

I've reworked my csv import so the values are in yyyy-mm-dd format, and the step 7 import says

"There are errors in Purchase Date:

* The dates are invalid."

and the step 7 values contains the following :

[cck:field_purchase_date:value] => Array
(
[0] => 2008-03-18
)

I'm just not getting it...my csv has yyyy-mm-dd format, my CCK date field has Y-m-d format, my Set import options (step 5 of 8) has Y-m-d format (and custom format selected)

-James

Kristi Wachter’s picture

Hotspoons, I just wanted to say thanks for the -/+ tip in 45 - that was the one piece I needed to get date import to work for me.

Thanks!

snorkers’s picture

The only way I could get Dates to import using 6.x-1.x-Dev (22 Apr 09) was to set in CCK the Date format via 'Select List' (#47). All others failed.
Not correct. Select List (from Basic Information) is only the first step...
2. Had to ensure that Repeat Rules was disable in CCK content type
3. Then took out default values from CCK field
4. Then Customized Date Parts: For each element of the date/time, I selected the Text Field radio button(as opposed to Select List)

An after 2 days' effort, it looks like 500+ calendar entries are actually importing. Yay!

Now have to remember to put the CCK date fields in my content type back to something user friendly.

PS. Apologies to any email subscribers for re-editing this twice.

ndm’s picture

I've tried with patch 56 it's work for the other widget, very thanks.

But you can't have the "to date", the problem is here. not in date field but in date field with to date.

davegan’s picture

I managed to import by doing the following:
1) Change widget to select list
2) Change date range to +/- 10 years
3) Convert my dates to unix timestamps

Only 4 hours later...

alduya’s picture

The patch in #56 works for me. I'm using date pop-ups as input and required To date.
I hope this module will make it to the next version because it really looks promising. Keep up the good work.

DartonW’s picture

See http://drupal.org/node/477392#comment-2111134, it may be related to some of the problems discussed here.

squarecandy’s picture

So close I can taste it:
using Date 6.x-2.4, Node Import RC4 with date.inc from #55.
Date field using jquery popup; Default value is "now"; Default value for To date is "blank";
Input format: MM/DD/YYYY; Granularity: Year Month Day

Happy to report everything works great if both From and To dates are supplied. But if the to date is blank, it fills in 12/31/1969. Now the To date is before the From date, and it throws the simple error "The To date must be greater than the From date."

It's important in this context to be able to import a blank To date - not this odd default 1969 date. Can anyone point me in the right direction?

Thanks!

  [field_member_startdate] => Array
        (
            [0] => Array
                (
                    [value] => Array
                        (
                            [date] => 12/10/2007
                            [time] => 
                        )

                    [value2] => Array
                        (
                            [date] => 12/31/1969
                            [time] => 
                        )

                )

        )
squarecandy’s picture

FileSize
7.85 KB

Figured it out... sweet. This helped me:
http://us.php.net/manual/en/function.strtotime.php#60579

The default values that are entered if there is no value get skipped if there is a From date but no To date - plus you still want it to evaluate the From date, so I re-checked for a FALSE result to $time. Weird that date(FALSE) returns "12/31/1969", right? How is that useful?

Thanks GuyPaddok and AlexK for the work on this. Is this planned for inclusion in RC5?

oadaeh’s picture

FileSize
8.33 KB

I'm adding my piece to this puzzle. My issue was that the code in date.inc wasn't taking into account custom date definitions. The attached file does.

hansrossel’s picture

#89 works for me with node_import rc4 and dates in format 18/10/2009 - 00:00
Thanks!

seehawk’s picture

I'm having big problems importing dates as well. Not sure what I'm doing wrong.

I added the patch from #89 to the Oct 10 dev version. Made sure none of the date fields in the content type are required. Set them all to the Select List widget, +10:-10, hour and minute granularity. It's still not working. I keep getting "The dates are invalid." on step 7 of the import.

One of the fields is part of a content multigroup from CCK3, but I still get the error even when I don't import that field. The other 4 date fields in that content type are single-value fields ("from" date, but no "to" date). In the .csv I'm importing, dates look like this: "08/16/2006 - 00:00", and I'm using the matching date format in step 5 (the default format).

Dates all display like this on the output from step 7:

[cck:field_date_sent:value] => Array
(
[0] => 2006-08-16T00:00:00
)

I've been wrestling with this thing for a couple days now, and at this point, I'm completely lost. Can anyone suggest something else that I can try? Any ideas would be welcome!

legion80’s picture

The date.txt from #89 does not fold in the fix regarding historical dates. strtotime() returns FALSE for me.

I need to fold back in the fix by replacing this line (108 in the attachment in #89):

  if ($time == FALSE) {
          $values[$fieldname][$i][$colname]['date']  = '';
        }
  else {
          $values[$fieldname][$i][$colname]['date']  = date($widgetFormat, $time);
        }

to

  if ($time == FALSE) {
          $values[$fieldname][$i][$colname]['date']  = $value[$colname];
        }
  else {
          $values[$fieldname][$i][$colname]['date']  = date($widgetFormat, $time);
        }
froboy’s picture

Subscribe

Cayenne’s picture

Subscribing. Edited prior issue out.

kruser’s picture

subscribing

Aren Cambre’s picture

Assigned: vinothg » Unassigned

Removing improper assignment from #24.

asb’s picture

Hi,

Imports with the date.inc.txt from #89 added to 6.x-1.0-rc4 do work somehow for me; however, the results are absolutely useless: as well the date as the CCK text field is empty in the created nodes (imported CSV file just contains two fields, a date and a description, shouldn'tbe too hard); the only thing that really gets "imported" is the node title. It seems to simulate the import operation and only bulk create nodes. No errors are given.

Settings: "Delimiter Separated Values", Record separator "Newline", Field separator "Pipe (|)", Text delimiter "none", Escape character "none".

Date field: Default "empty", "To"-date: "empty", "To"-date: "never". As simple as it gets, one should think.

With the latest 6.x-dev from 2009-Oct-10 it's the other way around: the CCK date field seem to be supported by default, but imports fail at "Preview import (step 7 of 8)" with the error: "There are errors in Datum: The dates are invalid". I tried this at first with a granularity limited to Year and month (sometimes wonders do happen) and then with bogus day data (granularity: Year/Month/Day), formatted like "2001-01-01T00:00:00". This also fails with the error mentioned above, even if the date field was configured accordingly.

The debugging array look like follows:

values = Array
(
    [created] => 1209300093
    [node_import_build_mode] => 1

    ...

    [cck:field_datum_ereignis:value] => Array
        (
            [0] => 2008-04-01T00:00:00
        )

    ...

    [field_datum_ereignis] => Array
        (
            [0] => Array
                (
                    [value] => 2008-04-01T00:00:00
                )

        )
    ...

My this and last import used dates formatted like "2001-01-01", same granularity of the CCK date field (Year/Month/Day), formatting Y-m-d.

Same error; excerpt from array:

    [cck:field_datum_ereignis:value] => Array
        (
            [0] => 2001-01-01

This is highly frustrating :-(

Greetings, -asb

asb’s picture

This must be a bad joke; the 'Node import' module doesn't even bother to import one single textfield from a CSV file into one one CCK multiline text field. Nodes are created, titles are filled in, but all CCK fields are empty.

Has someone ever succeeded in importing anything into CCK fields with 'Node import'? I'd be rather interested in the import parameters...

Greetings, -asb

alex.k’s picture

Could be a regression introduced with later versions of CCK. Import worked for pretty much all core CCK fields with CCK 2.1/2.2

Cayenne’s picture

I've done tons of imports into CCK fields with Node Import. Only dates were tricky... Got'em now.

Aren Cambre’s picture

Did we ever determine whether this is a problem with Node import or Date?

savageanne’s picture

#89 solved my simple date import issue. Thanks to all.

bibo’s picture

Priority: Normal » Critical

I'm in the same situation as asb at #97. "Highly frustrated" would be a good definition of my current status after 3 workdays(!) of headbanging with this problem. I've tried all date.inc version and modifications in this thread, with node_import RC4, and the latest dev, and Date 2.2 and the dev-version.

Currently using node_import latest dev & date 2.4

My date cck settings should be ok (have tried all variations), currently with default values as "Blank", widget as "Select", "d.m.Y" as input format (and granularity). Select is using textboxes for each part. The date fields have "to date" and the field nor to date are required.

My imports seem to succeed, but the result is always empty, all my over 40 CCK fields just don't get imported, only the title is ok.

To get to the root of this, next thing im going to do is create a dummy content type called "test", with one CCK date field. Then im trying (again) all settings, patches, module versions and CSV import data types. Sounds fun, doesn't it.

marrch_caat’s picture

Patch in #89 worked well for me. Almost everything worked fine, except for taxonomy term import, that produced errors, so I had to remove mapping for that field :( dunno why...

bibo’s picture

Status: Active » Reviewed & tested by the community

In the end #89 worked for me aswell. Didn't have time to report back in the hurry before christmas.

Still I had this very weird bug while importing with #89. The nodes first appeared blank! That is, there was no CCK information visible on the node view and edit pages except the title.

However, to my surprise I found the data in the CCK tables, for the exact same nodes. Page refreshes didn't fix anything, but clearing all Drupal caches fixed everything, the CCK information magically appered!

What worked for me with patch from #89 was:
- node_import 6.x-1.0-rc4
- date 6.x-2.4
- All the CCK Date fields setting optimations mentioned above. I think maybe only the SELECt-thing and maybe "+/-10" years were necessary in the end with #89.
- Cache clearing immediately after import!

Downgrading from node_import 6.x dev to 6.x-1.0-rc4 required some manual db-settings ("file_offset" fields). I added the old "offset" column as a new column. Without the changes the import would fail because of SQL errors.

Having to clear the cache seems weird (I had all page caching off, although that's supposed to only affect anonymous users anyway).
Maybe a $node cache reset for each imported node could maybe fix the cache problem. ( node_load($nid, NULL, true); )

Aren Cambre’s picture

Status: Reviewed & tested by the community » Needs review

Since #105 points out problems, this needs to have needs review status.

bibo’s picture

Status: Needs review » Reviewed & tested by the community

I believe the cache problem originates from the signup module:
http://drupal.org/node/605594

There is a simple patch that should fix it (hasn't been committed to any signup version yet).

#89 seems is not at fault, so I hope it gets committed soon => setting issue again to reviewed & tested.

nw’s picture

I wrote a fix to this bug before finding this issue!

In essence what I have done is very similar to the patch in #89. However, my code is about 20 lines compared with 200 lines in #89. My modified function is copied below for comparison to #89. Given that #89 has had more community debugging than my code, it may have less bugs.

function date_node_import_values_alter(&$values, $type, $defaults, $options, $fields, $preview) {
  foreach (node_import_cck_fields($type, 'date') as $fieldname => $fieldinfo) {
    foreach ($fieldinfo['columns'] as $colname => $colinfo) {
      $cck_fieldname = node_import_cck_name($fieldname, $colname);
      foreach ($values[$fieldname] as $i => $value) {
      
      	/* Get array from (converted) date from file 
         NB array includes the timestamp value */
      	$date_in = $value[$colname];
      	$date_array = date_convert($date_in, DATE_ISO, DATE_ARRAY);
      	$timestamp = $date_array[0];
      	
      	/*Determine format req'd by CCK date widget */
      	$format = $fieldinfo['widget']['input_format'];
      	if ($format == 'custom') $format = $fieldinfo['widget']['input_format_custom'];
      	
      	/* Store values in form expected by widget validate functions */
      	switch ($fieldinfo['widget']['type']) {
      		
      		case 'date_pop_up':
      		case 'date_pop_up_repeat':
      			$time_format = date_limit_format($format, array('hour', 'minute', 'second'));
      			$date_format = date_limit_format($format, array('year', 'month', 'day'));
      			$date = date($date_format,$timestamp);
      			$time = date($time_format,$timestamp);
      			$values[$fieldname][$i][$colname] = array('date'=>$date,'time'=>$time);
      			break;
      		case 'date_text':
      			$date = date($format,$timestamp);
      			$values[$fieldname][$i][$colname] = array('date'=>$date);
      			break;
      		case 'date_select':
            case 'date_select_repeat':
            	$values[$fieldname][$i][$colname] = $date_array;
            	break;
      	}
       }
    }
  }
}
Aren Cambre’s picture

Status: Reviewed & tested by the community » Needs review

Setting back to needs review because of proposed improvement.

semperos’s picture

Will re-post what I wrote at a later time.

portalmanagers’s picture

I am getting this error message:

"Input error: 12/06/2009 - 11:00am is not allowed for Date (not a date in 01/17/2010 - 8:57pm format)."

My date formats in CSV file is EXACTLY as requested but I continue to get this same input error message.

Does anyone have suggestions for novice on how to resolve this error?

tripper54’s picture

My problem was related to incorrect zero padding of minutes. I tried the patch in #44, but it broke other rows that previously imported without a problem.

It seemed minutes need to be padded with a leading zero, but hours should not be. I commented out the line from the patch that padded the hours, and my dates import fine now.

I hope this helps someone.

AbhyK’s picture

hi everyone,

Use Date as type instead of Datetime for the field in content type it works fine and for every date it will assign value time stamp as T00:00:00 so it is stored in database as

vid nid field_test_date_csv_value
704 704 1969-12-31T00:00:00
705 705 1970-01-01T00:00:00
706 706 1970-01-02T00:00:00
707 707 1970-01-03T00:00:00

our field name is test_date_csv

you can customize date format as m-d-Y or use php manual

hope it will help someone as it work for us.

Cyberwolf’s picture

Subscribing.

bneel’s picture

#89 works well thanks
Ben

geerlingguy’s picture

Using the patch in #88 I get the following error:

Fatal error: Cannot unset string offsets in [...]sites/all/modules/date/date_repeat/date_repeat_form.inc on line 212

Hrm...

tttimi’s picture

Hi,

almost everything works fine with patch #89, the sample data seems fine, yet when I strat to import, I get the following warning:
user warning: Unknown column 'file_offset' in 'field list' query: INSERT INTO node_import_tasks (name, uid, created, changed, fid, has_headers, file_options, headers, type, map, defaults, options, file_offset, row_done, row_error, status) VALUES ('events1-15.csv', 1, 1266828542, 1266828542, 30, 1, 'a:10:{s:11:\"file_format\";s:9:\"csv-excel\";s:16:\"record separator\";s:9:\"\";s:22:\"other record separator\";s:0:\"\";s:15:\"field separator\";s:1:\";\";s:21:\"other field separator\";s:0:\"\";s:14:\"text delimiter\";s:1:\"\"\";s:20:\"other text delimiter\";s:0:\"\";s:16:\"escape character\";s:1:\"\"\";s:22:\"other escape character\";s:0:\"\";s:5:\"title\";s:26:\"Semicolon Separated Values\";}', 'a:8:{i:0;s:5:\"ev_id\";i:1;s:8:\"ev_start\";i:2;s:6:\"ev_end\";i:3;s:13:\"ev_attandance\";i:4;s:8:\"ev_title\";i:5;s:8:\"ev_venue\";i:6;s:7:\"ev_note\";i:7;s:13:\"ev_reportfile\";}', 'node:date', 'a:13:{s:5:\"title\";s:1:\"4\";s:29:\"cck:field_ev_attandance:value\";s:1:\"3\";s:21:\"cck:field_eleje:value\";s:1:\"1\";s:23:\"cck:field_ev_note:value\";s:1:\"6\";s:24:\"cck:field_ev_venue:value\";s:1:\"5\";s:22:\"cck:field_eleje:value2\";s:1:\"2\";s:3:\"uid\";s:0:\"\";s:7:\"created\";s:0:\"\";s:6:\"status\";s:0:\"\";s:7:\"promote\";s:0:\"\";s:6:\"sticky\";s:0:\"\";s:7:\"comment\";s:0:\"\";s:4:\"path\";s:0:\"\";}', 'a:8:{s:7:\"comment\";s:1:\"0\";s:3:\"uid\";s:5:\"admin\";s:7:\"created\";s:0:\"\";s:3:\"log\";s:26:\"Imported with node_import.\";s:6:\"status\";s:1:\"1\";s:7:\"promote\";s:1:\"0\";s:6:\"sticky\";s:1:\"0\";s:4:\"type\";s:4:\"date\";}', 'a:2:{s:21:\"cck:field_eleje:value\";a:3:{s:8:\"timezone\";s:15:\"Europe/Budapest\";s:11:\"date_format\";s:9:\"Y-m-d H:i\";s:11:\"date_custom\";s:0:\"\";}s:22:\"cck:field_eleje:value2\";a:3:{s:8:\"timezone\";s:15:\"Europe/Budapest\";s:11:\"date_format\";s:9:\"Y-m-d H:i\";s:11:\"date_custom\";s:0:\"\";}}', 0, 0, 0, 0) in /www/data/intranet/includes/common.inc on line 3467.
What can be the problem?

oadaeh’s picture

@tttimi: The error you are getting has nothing to do with this issue. Your query for adding a data source is including the 'file_offset' column that is not in the 'node_import_tasks' table of your database. My first guess would be that the Node Import module did not get installed correctly on your site. Try disabling /and/ uninstalling the module, then try reinstalling it. If you get any errors, stop and resolve them first. if not, try importing again and see if it works. If not, then you'll have to resolve that problem in another issue.

mvc’s picture

FileSize
711 bytes

for what it's worth, patch #89 worked for me after i applied this patch to node_import.inc, which accepts a wide range of date formats using php's strtodate().

osu_bucks’s picture

I'm getting the following errors when I import csv with date format: 8/24/2009 from csv. Will #89 fix my issue? I'm currently using 6.x-1.x-dev 2010 Feb-06, will I need to revert back to rc4 to apply the patch? Sorry... I'm a newbie with Drupal :)

warning: date_offset_get() expects parameter 1 to be DateTime, null given in /home/public_html/test.com/public/sites/all/modules/date/date/date_elements.inc on line 495.
warning: date_offset_get() expects parameter 1 to be DateTime, null given in /home/public_html/test.com/public/sites/all/modules/date/date/date_elements.inc on line 498.
warning: date_offset_get() expects parameter 1 to be DateTime, null given in /home/public_html/test.com/public/sites/all/modules/date/date/date_elements.inc on line 499.
warning: date_offset_get() expects parameter 1 to be DateTime, null given in /home/public_html/test.com/public/sites/all/modules/date/date/date_elements.inc on line 501.

dom_b’s picture

Same issue. My date input is absolutely correct but always get the same error.

sunny.oxide’s picture

Version: 6.x-1.0-rc4 » 6.x-1.x-dev

Patch in #89 works for me in 6.x-1.x-dev as of 2010 March 5th. Hope it gets into -dev soon.

rickmanelius’s picture

I've tried various combinations of all patches given... but I still get the "illegal" warning despite trying 6 hours of input and custom field variations. As soon as I turn off the date module, node imports work. If I do a to AND from date... I get 2 illegal warnings.

I'm using the very latest version of date, node import, and the patches listed above.

erwin k’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc4
Priority: Critical » Normal

Used the date.inc from #89, used it as describe in #3

Options used:
-no column names
-semicolon sep. values
-custom format for date field

All rows and columns were imported, of which one column with a custom j/m/Y format
(and not relevant here, but still, one column with title of nodereference field)

geerlingguy’s picture

Version: 6.x-1.0-rc4 » 6.x-1.x-dev

Patch should still be made against -dev version.

twooten’s picture

FileSize
7.59 KB

My CSV file has dates like "2003-10-01 08:17:49". I am attaching the error I keep getting. I am using the simple Date field type with select list.

Also using node_import-6.x-1.x-dev

Any ideas why it is giving me an error about the format?

oadaeh’s picture

Try specifying a custom date format of "Y-m-d H:i:s" in the date configuration area of your import process. (I don't remember the name of the area, and I no longer have it available.)

The format of your data needs to match the format of your content type, which needs to match the format of the import.

erwin k’s picture

re #125, sorry about that, saw only now that what I did changed the issue's overall values.

jday’s picture

#89 applied to dev worked for me with the exception of rows with single or empty date values, so I had to split my cvs file into three separate imports

1. rows with to and from dates
2. rows with only start dates
3. rows with blank date fields

rukaya’s picture

#89 worked for me with dates in a 'Y-m-d' format, ie 2010-03-29. I was using a cck date field in content_profile, the date field was a custom input one, 'text field with custom input format'. I had to change :

if (($date = date_convert_from_custom($value, $input_format))) {
// It is useless to check for date_is_valid() as it is a DATE_DATETIME already.
$value = date_convert($date, DATE_DATETIME, $output_format, $timezone);
return TRUE;
}

to

if (($date = date_convert_from_custom($value, $input_format))) {
// It is useless to check for date_is_valid() as it is a DATE_DATETIME already.
// $value = date_convert($date, DATE_DATETIME, $output_format, $timezone);
$value = date_convert(strtotime($date), DATE_DATETIME, $output_format, $timezone);
return TRUE;
}

in node_import.inc, though.

Aren Cambre’s picture

Status: Needs review » Needs work
d.cox’s picture

The file from #89 with latest dev release March 20, 2010, and also setting my Date CCK field to "YYYY-MM-DD - 00:00:00" worked for me.

andrewfn’s picture

After many frustrating hours, and final success, I thought it might be worth sharing my discoveries:

  1. No success with times in am/pm format, use 24 hour format
  2. The CCK field must be set up to collect data using selects, not a pop-up, as mentioned above
  3. Any date that would be invalid to enter using the CCK form will also fail node-import (e.g. outside the year-range specified, or the minute/second granularity)
  4. I found the format: YYYY-MM-DD hh:mm to be the most trouble-free
  5. It is essential to use the version of date.inc in #89 or nothing will work
  6. Data that had an optional to-date caused problems, so I just imported the from-date

Hope that helps somebody.

edg’s picture

Custom dates worked with date.inc file (#89) installed in rc4, although I did have to have to set up the CCK field in my content type to YYYY-MM-DD HH:MM:SS as recommended above by KarenS. Thanks all for posting!

lee20’s picture

Subscribing. I was able to get #89 to work with the suggestions from #133.

Cyberwolf’s picture

date.inc of #89 did the job here as well, with input format YYYY-MM-DD hh:mm, no to-date.

dandaman’s picture

Like lee20 said, I was able to get #89 to work with the suggestions from #133. Very helpful.

seaneffel’s picture

Status: Needs work » Reviewed & tested by the community

Seems like a couple of people reporting back success with the help of the .inc file in #89 and the tips in #133.

I'm marking this as RTBC and now let's hope for some sweet maintainer lovin'.

linneawilliams’s picture

Ditto with #133.

I installed the most recent development version of node import and the file in #89, which I have gotten to work.

DATE FORMATTING:

in the csv file:
I'm using a "MM/DD/YYYY - HH:MM" in php it's "m/d/Y - H:i" format. (be sure to use a hyphen, not a dash, which Open Office will sneak in while you aren't looking).

in node import:
the same format is also the default.

in the field settings:
be sure that you are importing values that you have allowed.
Some examples: if the field is set to have no seconds, don't try to import seconds. if the minutes are allowed in 5min increments, don't try to import a date with time 12:33. If the field is set to have dates +3 or -3 years, don't try to import a date that's 20 years ago. These all triggered the good ol' "An illegal choice has been made. Please, contact the site administrator."

Hope this helps others who are struggling. You can do it!

geerlingguy’s picture

For those using Excel to message the data, you will need to set the date column to use the following custom format (under Format > Cells...): mm/dd/yyyy - hh:mm

You'll also need to save as Windows CSV rather than plain-vanilla CSV.

I'm still getting:
Fatal error: Cannot unset string offsets in /home/archstl/public_html/sites/all/modules/date/date_repeat/date_repeat_form.inc on line 212

Here's the line from date_repeat_form.inc:
if (array_key_exists('BYDAY', $form_values)) unset($form_values['BYDAY']['']);

I configured the date field to use the exact same format as the imported values (MM/DD/YYYY HH:MM) with 24-hour timestamps, and it's still not working for me :(

Could it be that I have optional 'To' dates and optional repeat options allowed for this date field?

[Edit: I was finally able to get everything working together, after a lot of tinkering; I had to add the dash to separate the date from the time, and set the date field to use a select list instead of the date popup... I think this patch should try to account for differing settings if at all possible; this is not user-friendly :-(]

chadhester’s picture

Working with this right now... I have a ton of dates that use Unix Timestamp values. What I'll likely do is scrub the data in Excel (ack!), and prep the dates using a formula like:

=YEAR((K2 / 86400) +DATE(1970,1,1))&"-"&REPT("0", 2-LEN(MONTH((K2 / 86400) +DATE(1970,1,1))))&MONTH((K2 / 86400) +DATE(1970,1,1))&"-"&REPT("0", 2-LEN(DAY((K2 / 86400) +DATE(1970,1,1))))&DAY((K2 / 86400) +DATE(1970,1,1))

Which yields something like "2010-05-26", where cell "K2" is a Unix Timestamp value. Note that I don't need the time portion, so I intentionally do not include this.

Otherwise I would use this:

=YEAR((K2 / 86400) +DATE(1970,1,1))&"-"&REPT("0", 2-LEN(MONTH((K2 / 86400) +DATE(1970,1,1))))&MONTH((K2 / 86400) +DATE(1970,1,1))&"-"&REPT("0", 2-LEN(DAY((K2 / 86400) +DATE(1970,1,1))))&DAY((K2 / 86400) +DATE(1970,1,1))&" "&REPT("0", 2-LEN(HOUR((K2 / 86400) +DATE(1970,1,1))))&HOUR((K2 / 86400) +DATE(1970,1,1))&":"&REPT("0", 2-LEN(MINUTE((K2 / 86400) +DATE(1970,1,1))))&MINUTE((K2 / 86400) +DATE(1970,1,1))

Which yields something like "2010-05-26 15:34".

Hopefully this helps someone as much as it helped me. :)

nally’s picture

What if all my nodes for import have To parts to the Date field. Has anyone had success where every row has a range? (wish me luck!)

Rob_Feature’s picture

After reading all the issues above, and trying every possible combination, it seems that there is one thing that hasn't been fixed in all of this (unless I missed it):

I have 'to date' as 'optional'. Some of my imports have a to date, and some do not. Any record with a blank 'to date' gives me "An illegal choice has been detected. Please contact the site administrator." while any record that has a 'to date' imports fine.

Notes:

  • I'm using the select list widget
  • My 'to date' is optional
  • My 'from date' and my 'to date' defaults are both blank
  • I tried patches from #88 and #89 with no luck

To clarify, has anyone had optional 'to date' (in which some records have one, and some don't) work on import? I know my date formatting must be correct because other records (with a 'to date' record) work fine.

dystopianblue’s picture

Status: Reviewed & tested by the community » Needs review

For those who are receiving the "An illegal choice has been detected. Please contact the site administrator." message and are trying to import a blank date or a date that doesn't have a "to date" value, try editing date.inc from #89 so that the array on line 205 contains only null values:

array
(
'year'    => null,
'hour'    => null,
'minute'  => null,
'second'  => null,
'month'    => null,
'day'    => null
);

That seems to fix the problem for me.

Encarte’s picture

subscribing

nwe_44’s picture

subscribing

agerson’s picture

I would like to confirm that #44 combined with #112 do fix the issue with :00 minutes.

However, when I switched my CCK date field from select back to pop up, it wiped out all the dates.

Would it not be wise to break these date realted issues up into smaller chunks? It appears as if there are many separate problems with date that could be better tackled with separate issues. The module maintainer could create a separate "component" for date related issues to keep them all grouped together.

anonymous07’s picture

Subscribe

UPDATE: SOLVED! With the hints in this very thread.

Here is the road map:

Good outline in this post: http://drupal.org/node/464114#comment-2558762 + Disable Date Popup =
Solved it for me

I am using Node_Import + CCK + Date + Scheduler + Rules to Import Nodes that will be published and unpublished on dates provided in the CSV. This all worked perfectly in D5.

It DOES work now in D6 for me using the above road map

Still some relatively minor issues:
1) Still get error during the import process (even though it DOES finish successfully) -

"You need to have Javascript enabled to see the progress of this import"
An error occurred. /admin/content/node_import/xx/continue (no information available).

See: http://drupal.org/node/836360
and in the log it is,

  Location: "/admin/content/node_import/xx/continue"
  Message: "Cannot modify header information - headers already sent by (output started at ...www/web1/web/sites/all/modules/rules/rules/modules/php.rules.inc(107) : eval()'d code:22) in www/web1/web/includes/common.inc on line 148

it is due to some extra spaces in the PHP code that I have not found, see: http://drupal.org/node/128832

2) Still have to change the Date Custom Format for every import from the default m/d/Y H:i

3) Publish on Dates in the past are changing to 1969-12-31 20:33:30; right now I don't care as long as this does not happen to Publish on dates that are in the future

4) I just have figure out how to now change Meta tags while using Nodewords which used to work fine in D5

locomo’s picture

subscribe

dcomfort’s picture

I was having similar issues importing dates into a CCK field. I tried different combos of formats. A simple solution turned out to be changing the date field to a select list and the import goes through fine.

el56’s picture

Subscribe

lentreprenaute’s picture

A simple solution turned out to be changing the date field to a select list and the import goes through fine.

So i dont' know why, i wasn't enable to import Date but i changed the field format to select list like say Dcomfort... with succes.!!! Thank.

Flo

yanosz’s picture

Hi,

same problem here. However, I was not able to circumvent it, as described above. (dev release, 2010-Jul-11)
Is there a another way to import date / time fields?

bmango’s picture

subscribe

Aren Cambre’s picture

Status: Needs review » Needs work

Per above comments, new patch needed that addresses some problems.

Junro’s picture

Did you tried the Feed module to import nodes? http://drupal.org/project/feeds

It seems to be much more powerful and it's well maintained.

Marko B’s picture

subs

NaX’s picture

Status: Needs work » Needs review
FileSize
7.76 KB

I was getting the follow errors when trying to do an import of nodes with 2 date fields using a custom format using UTC.

- PHP date module function errors as described in #120
- Optional empty dates = An illegal choice has been detected. Please contact the site administrator.

I took the date.inc file from #89 and incorporating the historical dates fix from #92 and reformatted it to be more in-line with Drupal coding standard.

And all my errors disappeared.

Thanks to everyone that worked on this.

I also tried the fix suggested at #108, but this did not resolve any of my errors.

Attached is my date.inc file.
Hope it helps.

Hummad’s picture

Priority: Normal » Major
Status: Needs review » Active

I am using the date.inc as described in # 158 and the getting the following error in the Preview import (step 7 of 8) and of-course the required file is there:

Upload a file first.

values = Array
(
[created] =>
[node_import_build_mode] => 1
[title] => ENGRO
[cck:field_openrate:value] => Array
(
[0] => 98
)

[type] => price
[cck:field_highrate:value] => Array
(
[0] => 0
)
[cck:field_closerate:value] => Array
(
[0] => 98
)
[cck:field_volume:value] => Array
(
[0] => 0
)
[cck:field_trandate:value] => Array
(
[0] => 1991-01-01
)
[cck:field_lowrate:value] => Array
(
[0] => 0
)
[cck:field_tot_ret_price:value] => Array
(
[0] => 7.51
)
[cck:field_adjust_price:value] => Array
(
[0] => 14.98
)
[cck:field_symbol:value] => Array
(
[0] => ENGRO
)
[uid] => 1
[revision] => 0
[log] => Imported with node_import.
[sticky] => 0
[status] => 1
[promote] => 0
[path] =>
[name] => admin
[taxonomy] => Array
(
)
[field_openrate] => Array
(
[0] => Array
(
[value] => 98
)
)
[field_highrate] => Array
(
[0] => Array
(
[value] => 0
)
)
[field_closerate] => Array
(
[0] => Array
(
[value] => 98
)
)
[field_volume] => Array
(
[0] => Array
(
[value] => 0
)
)
[field_trandate] => Array
(
[0] => Array
(
[value] => 1991-01-01
)
)
[field_lowrate] => Array
(
[0] => Array
(
[value] => 0
)
)
[field_tot_ret_price] => Array
(
[0] => Array
(
[value] => 7.51
)
)
[field_adjust_price] => Array
(
[0] => Array
(
[value] => 14.98
)
)
[field_symbol] => Array
(
[0] => Array
(
[value] => ENGRO
)
)
[op] => Preview

d.cox’s picture

#158 I though worked, but now I'm getting the "An illegal choice has been detected. Please contact the site administrator".
Log is saying "Illegal choice 18 in Hour element."

Hummad’s picture

The mentioned "Upload a file first" was due to conflict with Feeds Module. Once Feeds was un-installed and resolution of # 158 worked fine and the nodes are being imported.

boran’s picture

#158 worked for me

Renee S’s picture

#158 Worked for me. Thanks.

geerlingguy’s picture

I've tried #158, and I'm still getting the same error I got in #140:

Fatal error: Cannot unset string offsets in /home/archstl/public_html/sites/all/modules/date/date_repeat/date_repeat_form.inc on line 212

This error only goes away if I change the date field's input widget to a simple text field with custom input format.

benone’s picture

@NAX from #158: THANK YOU!

oldmoonlake’s picture

used the latest 6.x-1.x-dev as 11th, July and date.inc from #158, everything works like a charm. Thanks.

vadym.kononenko’s picture

Status: Reviewed & tested by the community » Active

latest 6.x-1.x-dev and date.inc from #158. All works correctly too.
Field widget - text field with popup calendar

bibo’s picture

Status: Active » Reviewed & tested by the community

#158 works. Commit this please?

monotaga’s picture

Status: Active » Reviewed & tested by the community
FileSize
6.94 KB

The changes in #158 http://drupal.org/node/374346#comment-3566770 seem to work for me at this point, too.

I've created a patch based on the changes in #158.

lukus’s picture

The changes in #158 worked for me as well.

nicknickoli’s picture

#158 did not work for me with select-list date fields. I updated to dev releases on the date and node_import modules. The patch changed an "Illegal choice 0 in Second(minutes, hour) element" to "Minute (hour, month, day, year) field is required."

My date from the debug or csv is 2010-10-15 00:00. It would help me debugging to access #post values directly. I'm not seeing them in any hooks if validation fails?

Aren Cambre’s picture

Status: Reviewed & tested by the community » Needs review
naero’s picture

I had an issue importing a custom date format into a CCK date field "Published", error message read:

There are errors in Published:
• The dates are invalid.

I took suggestion #22 into account, switched my CCK field's widget from "popup date selector" to a select field, and this worked. After my import, I switched it back to the popup selector.

daniel-san’s picture

Was having difficulty with node import giving errors on date format for cck field using datetime. We would get errors for invalid format over and over no matter how we adjusted the date format on the import.

Applied patch from #169 and imported all of the event nodes with dates successfully.

Thank you for the work on this.

Dan

twowheeler’s picture

Works for me as well. Nice work.

Robrecht Jacques’s picture

Status: Needs review » Fixed

#156 commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

roshan_pant’s picture

Status: Closed (fixed) » Active

*********Useing node import from excel file -----step by step---****************************

# Modules
* cck
* node import
* token
* date API

# To Rememmber
* Use Always Date ISO format - yyyy-mm-dd or yyyy-mm-dd hh:mm:ss
* Make sure your CSV file has same date format

# Create Content Type
* i had problem while using jQuery_ui module and Date Popup for pop up calendar so i suggest that don't use it.
* select type 'date' of your content type.
* i suggest select operation 'select type'.
# Create your conntent

Thank You
From: roshan.pant@gmail.com
******************************************End************************************

Encarte’s picture

Status: Active » Closed (fixed)
Uv516’s picture

Version: 6.x-1.x-dev » 6.x-1.2

The problem is not solved.
The issue is the date.inc file, line 145: $widgetFormatPieces = explode(' - ', $widgetFormat, 2);
The line is assuming only that the widget between date and time is ' - '.
The administrator is allowed to create other datetime formats with other widgets. Sometime I use 'd-m-Y, H:i'. That would not be solved correct in line 145 because of ', ' instead of ' - '.
Many datetime formats uses d-m-y H:i (with just one space).

Instead of line 145 ($widgetFormatPieces = explode(' - ', $widgetFormat, 2);) I have inserted this:

       if(strpos($widgetFormat,' - ')>0){
         $widgetFormatPieces  = explode(' - ', $widgetFormat, 2);
       }elseif(strpos($widgetFormat,', ')>0){
         $widgetFormatPieces  = explode(', ', $widgetFormat, 2);
       }elseif(strpos($widgetFormat,' ')>0){
         $widgetFormatPieces  = explode(' ', $widgetFormat, 2);
       }

This will allow datetime formats of this:

  • [date] - [time]
  • [date], [time]
  • [date] [time]

Could someone make a better solution to allow other possible delimiters between [date] and [time]?
Perhaps someone could make a patch? (I can't)