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);
If you look at the code snippet I provided, I declare the field as a esriFieldTypeDate,
I saw it.
So when you do: DateTime d = new DateTime(); that inserts 12:00 AM into your record?
If yes, then you need to format the date before it goes in.
using System;
public class Example
{
public static void Main()
{
// Get the current date.
DateTime thisDay = DateTime.Today;
// Display the date in the default (general) format.
Console.WriteLine(thisDay.ToString());
Console.WriteLine();
// Display the date in a variety of formats.
Console.WriteLine(thisDay.ToString("d"));
Console.WriteLine(thisDay.ToString("D"));
Console.WriteLine(thisDay.ToString("g"));
}
}
// The example displays output similar to the following:
// 5/3/2012 12:00:00 AM
//
// 5/3/2012
// Thursday, May 03, 2012
// 5/3/2012 12:00 AM