Select to view content in your preferred language

Default date of 1970 for date field at 2.3

5898
15
06-09-2011 12:22 AM
MarkSmith
Occasional Contributor
Hello,

I have a date field in my layer with no default value defined in the database.  Users then use an API with the editor and attribute inspector to create features and populate the attributes - normal stuff.

At 2.2 when the user creates a shape, the attribute inspector pops up and the date field is empty.  If they click the field the date picker appears conveniently on today's date.  This is the behaviour I want and expect.

Now at 2.3 when the attribute inspector opens after adding a new shape, there is a date already in the date field of 01/01/1970.  It's not just me either, the Validate Attribute sample does the same thing: http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ed/ed_attributeInspectorValidate.html

Can anyone please tell me how to fix this?
0 Kudos
15 Replies
MarkSmith
Occasional Contributor
Thanks Kelly,

Just to clarify, I am not trying to set a default value, the problem at 2.3 is that a default value is automatically being set to 1970 for date fields.  This did not happen at 2.2.

If the behaviour of the date fields can be restored to how it behaves at 2.2 then that would be great.  Basically a null date value should not default to ANYTHING, let alone a random date of 1970, it should remain null until the user decides to input a date - and then the date picker should open on today's date for convenience.  This is how it worked at 2.2.

Thanks again for your help,

Mark.
0 Kudos
MarkSmith
Occasional Contributor
If the behavior has changed between 2.2 and 2.3 that may be a bug. I'll take a closer look.


Kelly,

Have you been able to find anything out about this?

Thanks,

Mark.
0 Kudos
derekswingley1
Deactivated User
Hi Mark,

I believe we fixed this at 2.4. Check out the What's New in 2.4 doc, specifically under bug fixes towards the bottom:
The editor widgets (attribute inspector, editor etc) display a default value of 1/1/1970 for null date fields. Null date values should display as null instead of the default date. (NIM070071)


Can you test with 2.4 and confirm?
0 Kudos
MarkSmith
Occasional Contributor
Hello,

Yes, this is now fixed at 2.4.  Thank you.

Mark.
0 Kudos
derekswingley1
Deactivated User
Thanks for confirming!
0 Kudos
DavidHollema
Deactivated User
Similar question, mind taking a look?  http://forums.arcgis.com/threads/45726-Editor-attribute-inspector-default-values?p=156031

The attribute inspector date calendar displays the date stored in the feature's date field. New fields don't have a value so the default date of January 1, 1970 is displayed. You can modify this by setting the date's value to the current date (or whatever value you'd like) when a new feature is created. To do this listen for the feature layer's 'onBeforeApplyEdits' event and update the date for the newly added feature(s). In the sample below 'pointsOfInterest' is the feature layer whose date field you want to update.

        dojo.connect(pointsOfInterest,"onBeforeApplyEdits",function(adds,updates,deletes){
          //update the date field for new features to be today's date.
            dojo.forEach(adds,function(add){
              add.attributes.notedate = new Date().getTime();
            });
        });

0 Kudos