Skip to main content
Kofax

Change date format of KIC date fields

3014628

Question / Problem: 

This solution describes a method to change the date format of any date field returned by KIC.

Answer / Solution: 

Use the following code in the BeforeMessageImport function:

//======================================
            DateTime MyDateTime;
            MyDateTime = new DateTime();

            // get the date created (KcsMessageReceptionTimeCreated  from msg - needs to be mapped in configuration to index field named 
FieldName)
            string dateCreated = GetFieldValue("FieldName", indexFields);

            // if the date is empty set it to now
            if (string.IsNullOrEmpty(dateCreated))
            {
                if (indexFields.ContainsKey("
FieldName"))
                {
                    indexFields["
FieldName"] = DateTime.Now.ToString("yyyy-MM-dd");
                }
            }
            else
            {
                string format = "yyyy-MM-dd"; // Here the date format can be changed
                MyDateTime = Convert.ToDateTime(indexFields["
FieldName"]);
                indexFields["
FieldName"] = MyDateTime.ToString(format);
            }
        }

    // get field value
    private string GetFieldValue(string fieldName, IDictionary<string, string> fields)
        {
            if (fields.ContainsKey(fieldName))
            {
                return fields[fieldName];
            }
            else
            {
                return string.Empty;
            }
//======================================


This will change the date format of the field "FieldName" to the value defined in format.
In this example it is set to yyyy-MM-dd.

Please see the following link for futher possible datetime format which can be used here:
http://www.csharp-examples.net/strin...rmat-datetime/

Applies to:  

Product Version
KIC All

 

 

  • Was this article helpful?