Select to view content in your preferred language

Formating field values

2598
12
05-13-2013 03:26 PM
MichaelMurphy8
Deactivated User
I'm trying to create a feature class with a number of fields, and I've got the data to load properly.  However; I'd like to format the Date field so that the ArcMAP (Identify) always displays the date and time when selected in ArcMAP.  Is there a way to specify the formatting for a specific field value?

Here's what I've got thus far... (I'd like for it to always display as YYYYMMDD HH:mm:SS UTC instead of the default of 12:00:00 AM)

        
public static IFeatureClass createFeatureClassWithSR(string fcn, IFeatureWorkspace fw, ISpatialReference sr, string filname) {
            IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
            IObjectClassDescription objDesc = (IObjectClassDescription)fcDesc;
            IFields fields = objDesc.RequiredFields;
            IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
            int shapeIdx = fields.FindField(fcDesc.ShapeFieldName);
            IField field = fields.get_Field(shapeIdx);

            IField f18 = new FieldClass();
            IFieldEdit f18Edit = (IFieldEdit)f18;
            f18Edit.Name_2 = "TOA";
            f18Edit.Type_2 = esriFieldType.esriFieldTypeDate;
            f18Edit.AliasName_2 = "TOA";
            f18Edit.IsNullable_2 = false;
            f18Edit.Editable_2 = false;
            DateTime d = new DateTime();
            f18Edit.DefaultValue_2 = d;
            fieldsEdit.AddField(f18);


Thanks
0 Kudos
12 Replies
LeoDonahue
Deactivated User
The example was just an example.

According to that example, if you declare "thisDay" the way they did, it would be in the format you want.

Wouldn't you do something like this:


DateTime thisDay = DateTime.Today;
f18Edit.DefaultValue_2 = thisDay;
0 Kudos
MichaelMurphy8
Deactivated User
When I create a FeatureClass, there doesn't appear to be a way to specify the formatting of the value.  In the example you've shown, the DateTime instance is initialized to a value of "Today".  However, the initialization of the DateTime instance is independant of the presentation format.  In ArcMap, when I select a feature using the "Identify" tool, the pop-up displays the DateTime value as MM/dd/yyyy hh:mm:s AM/PM.  I want to change that display format to yyyy-MM-dd HH:mm:ssZ.  Similarly, there's other field values in the same FeatureClass that I would like to display truncated.  For example, I only want to display 1 decimal place for certain fields.
0 Kudos
LeoDonahue
Deactivated User
However, the initialization of the DateTime instance is independant of  the presentation format.
Ok.

In ArcMap, when I select a feature using the  "Identify" tool, the pop-up displays the DateTime value as MM/dd/yyyy  hh:mm:s AM/PM.  I want to change that display format to yyyy-MM-dd  HH:mm:ssZ


You want to change ArcMap's Identify tool to display the format you want? Or are you attempting to create your own "identify" tool to do this?

If you are creating your own identify tool, why can't you format the date from mm/dd/yyyy to yyyy/mm/dd ?  That seems easy to do; get the date value, get the day, get the month, get the year, etc..., then rearrange it into the string you want.

In the layer properties, fields tab, there is a place where you can change number of decimal places shown for that field, but not for dates.
0 Kudos