Clear date field value

3812
7
Jump to solution
04-19-2012 10:29 AM
SteveLettau
New Contributor
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:

[editFeature.attributes setValue:nil forKey:@"SOURCE_DATE"];  ...  [editFeature.attributes setValue:NULL forKey:@"SOURCE_DATE"];  ...  [editFeature.attributes setValue:@"" forKey:@"SOURCE_DATE"];
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Steve,

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

[editFeature.attributes setValue:[NSNull null] forKey:@"SOURCE_DATE"];


Hope this helps!

Regards,
Nimesh

View solution in original post

0 Kudos
7 Replies
NimeshJarecha
Esri Regular Contributor
Steve,

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

[editFeature.attributes setValue:[NSNull null] forKey:@"SOURCE_DATE"];


Hope this helps!

Regards,
Nimesh
0 Kudos
SteveLettau
New Contributor
Wow, you are indeed the man!  Thanks for the help.  Steve
0 Kudos
SteveLettau
New Contributor
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
0 Kudos
NimeshJarecha
Esri Regular Contributor
AGSGraphic's setAttributeToNullForKey should work. I just re-tested it and it works like a charm.

Regards,
Nimesh
0 Kudos
SteveLettau
New Contributor
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.
0 Kudos
NimeshJarecha
Esri Regular Contributor
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
0 Kudos
SteveLettau
New Contributor
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
0 Kudos