+ Reply to Thread
Results 1 to 8 of 8

Thread: Clear date field value

  1. #1
    Steve Lettau
    Join Date
    Sep 2010
    Posts
    21
    Points
    1
    Answers Provided
    0


    0

    Default Clear date field value

    I'm working with an attribute value of field type DATE. I can successfully utilize a DatePicker to edit the field, however I'd also like the functionality to delete the value. I can provide the same functionality on a TEXT field by sending an empty string. For the DATE field, I'm assuming I need to pass something like a nil or NULL value to the field, however this is not working. Ideas?


    These doesn't work:

    Code:
    [editFeature.attributes setValue:nil forKey:@"SOURCE_DATE"];
    
    ...
    
    [editFeature.attributes setValue:NULL forKey:@"SOURCE_DATE"];
    
    ...
    
    [editFeature.attributes setValue:@"" forKey:@"SOURCE_DATE"];

  2. #2
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    489
    Answers Provided
    105


    0
    This post is marked as the answer

    Default Re: Clear date field value

    Steve,

    You can set NULL value in the DATE field like this...

    Code:
    [editFeature.attributes setValue:[NSNull null] forKey:@"SOURCE_DATE"];
    Hope this helps!

    Regards,
    Nimesh

  3. #3
    Steve Lettau
    Join Date
    Sep 2010
    Posts
    21
    Points
    1
    Answers Provided
    0


    0

    Default Re: Clear date field value

    Wow, you are indeed the man! Thanks for the help. Steve

  4. #4
    Steve Lettau
    Join Date
    Sep 2010
    Posts
    21
    Points
    1
    Answers Provided
    0


    0

    Default Re: Clear date field value

    Nimesh, I've run into a problem since upgrading my iOS SDK to 10.1.1. Now I cannot clear out dates using setAttribute:[NSNull null]. Also, when adding features through my app, all date fields are defaulting to January 1, 1970.

    I've tried the new setAttributeToNullForKey: but that didn't work either.

    Any idea what could be happening with my date fields after upgrade to 10.1.1?

    Thanks, Steve

  5. #5
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    489
    Answers Provided
    105


    0

    Default Re: Clear date field value

    AGSGraphic's setAttributeToNullForKey should work. I just re-tested it and it works like a charm.

    Regards,
    Nimesh

  6. #6
    Steve Lettau
    Join Date
    Sep 2010
    Posts
    21
    Points
    1
    Answers Provided
    0


    0

    Default Re: Clear date field value

    I may be missing something. I can use setAttributeToNullForKey, but instead of setting the value to Null, it reverts to 1/1/1970. To add some more info, I'm using ArcSDE 10.1 on SQL Server 2012.

    To add to the confusion, I can add a feature in ArcGIS Desktop and the date field defaults to NULL, but when I add (or edit) the feature through my iOS app, the date gets set to 1/1/1970. This wasn't the case with iOS SDK 2.3, it appeared when I upgraded to 10.1.

    I'm attaching a small screen shot from ArcCatalog to show the issue.
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	DATE_field.png‎
Views:	35
Size:	22.2 KB
ID:	23728  

  7. #7
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    489
    Answers Provided
    105


    0

    Default Re: Clear date field value

    Please intercept request/response from your app to server for further investigation. Do you see null is being sent to server from your app?

    Regards,
    Nimesh

  8. #8
    Steve Lettau
    Join Date
    Sep 2010
    Posts
    21
    Points
    1
    Answers Provided
    0


    0

    Default Re: Clear date field value

    I did and as far as I can tell, it's null. There's definitely no indication of 1/1/1970. I've logged an incident with technical support and will await word from them. Thanks, Steve

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts