Epicor Date data type in C#

What actual datatype is DATE expecting in Epicor? I am in C# and cant seem to satisfy it.

I’ve tried giving it a DateTime, DateTime?, and String.

It never complains, it just never uses my date either.

Wondering if you are working in a form customization, BPM? Which Table.Field(s)?
If you check the data dictionary… you’ll see some fields might be DateTime while others are Date.

For now, here are a few generic dates used in a form customization

// Get proposed due date
DateTime yourDate = DateTime.Parse(sArgs);

// Calc proposed days allowed
DateTime dToday = DateTime.Today;
var difference = yourDate - dToday;

// Store as an difference as an Integer
int iDays = difference.Days;

// convert
DateTime dateVal = Convert.ToDateTime(str);

// and this is part of an example is from the E10 Customization Guide
dtNeedByDate = Convert.ToDateTime(args.ProposedValue);
if (dtNeedByDate > System.DateTime.Today.AddDays(365))
{
MessageBox.Show(“Need By Date exceeds one year. Enter a valid Need By Date.”);

Thanks for the response Bruce. I am actually connecting from outside of Epicor. I am using the UD38Adapter.

Here is some relevant code (where my date isnt working proper):
See a.UD38Data.Tables[0].Rows[0][GetField(“Date1”)] = DateTime.Now;

UD38Adapter a = new UD38Adapter(oTrans);

       a.ClearData();
            string[] udparams = { pn,bin,lot, "" ,""};
            try
            {
                got = a.GetByID(udparams);
            }
            catch { }

            if (got) //found a record - do some shifting
            {
                decimal? count1 = (decimal)a.UD38Data.Tables[0].Rows[0][GetField("Count1")];
                decimal? count2 = (decimal)a.UD38Data.Tables[0].Rows[0][GetField("Count2")];
                decimal? count3 = (decimal)a.UD38Data.Tables[0].Rows[0][GetField("Count3")];

                DateTime? date1 = null;
                DateTime? date2 =null;
                DateTime? date3 = null;
                try
                {
                    date1 = (DateTime?)a.UD38Data.Tables[0].Rows[0][GetField("Date1")];
                    date2 = (DateTime?)a.UD38Data.Tables[0].Rows[0][GetField("Date2")];
                    date3 = (DateTime?)a.UD38Data.Tables[0].Rows[0][GetField("Date3")];
                }
                catch { }

                string user1 = a.UD38Data.Tables[0].Rows[0][GetField("User1")].ToString();
                string user2 = a.UD38Data.Tables[0].Rows[0][GetField("User2")].ToString();
                string user3 = a.UD38Data.Tables[0].Rows[0][GetField("User3")].ToString(); 

                //now do shifts as needed - we know we have count1 cuz we got record
            
                    count3 = count2;
                    count2 = count1;
                    date3 = date2;
                    date2 = date1;
                    user3 = user2;
                    user2 = user1;
            

                //last put the  current & shitfted data
                a.UD38Data.Tables[0].Rows[0][GetField("Count1")] = count;
                a.UD38Data.Tables[0].Rows[0][GetField("Count2")] = count2;
                a.UD38Data.Tables[0].Rows[0][GetField("Count3")] = count3;

                a.UD38Data.Tables[0].Rows[0][GetField("Date1")] = DateTime.Now;
                if(date2 != null) a.UD38Data.Tables[0].Rows[0][GetField("Date2")] = date2;
                if(date3 != null) a.UD38Data.Tables[0].Rows[0][GetField("Date3")] = date3;


                a.UD38Data.Tables[0].Rows[0][GetField("User1")] = currentUser;
                a.UD38Data.Tables[0].Rows[0][GetField("User2")] = user2;
                a.UD38Data.Tables[0].Rows[0][GetField("User3")] = user3;

                a.Update();

                }
                else  //not found, create
                {
                    baseCreateRecord(pn, bin, lot, count);
                }

            a.ClearData();

What is Date3? I assume you meant Date03 or did you create custom field? If custom, can you paste a screenshot of custom field properties?

I cheat with my field names by using a custom method to translate to a friendly name:


  public static string GetField(string field)
        {
            string res = "";
            if (!FieldMap.TryGetValue(field, out res)) throw new Exception("Check your field map sucker!");
            return res;
        }
        private void init_field_map()
        {
            FieldMap.Clear();
            FieldMap.Add("Part", "Key1");
            FieldMap.Add("Bin", "Key2");
            FieldMap.Add("Lot", "Key3");
           
            FieldMap.Add("Count1", "Number01");
            FieldMap.Add("Count2", "Number02");
            FieldMap.Add("Count3", "Number03");
            FieldMap.Add("Date1", "Date01");
            FieldMap.Add("Date2", "Date02");
            FieldMap.Add("Date3", "Date03");
            FieldMap.Add("User1", "Character01");
            FieldMap.Add("User2", "Character02");
            FieldMap.Add("User3", "Character03");
}

Essentially I am making a custom solution to perform a full inventory. It will allow parts to be counted up to 3 times (hence the user\date\count 1-3). Any part bin overages are moved to LOST bin. Do the actual qty adjustment on the overall part (against the LOST bin) - and log as needed. Then only part bin deficits exist - reconcile them from LOST. Should be left with 0 in LOST and count and actual values should match

1 Like

I think I’ve figured out my date confusion - I assume because of the time zone settings of the server being one hour ahead of me - I kept logging the day before at 11pm instead of today at 12am.

That’s kind of funky but at least I understand what is happening. I would be much better suited to store the time than the date anyway since this all happens in the span of one day.

After reading this, I have to say that it’s really nice to see @bordway and @danbedwards help @Chris_Conn get a date…

1 Like

https://m.popkey.co/20808d/O5wOj.gif

@Chris_Conn why don’t you just make the fields with the right name to being with? Why bother using those fields at all? Except Keys(1-5) you don’t need to use any of those fields. You can make your own with the proper names