Date a day off

I have a custom dashboard that is used to help populate UD09. One of the fields in UD09 is Date01. From my customization screen I used this code to assign a value to UD09.Date01 via callcontext.

edvCallContextBpmDataRow["Date01"] = MyDate.Text;

However, today we noticed that the date seems to be off. When I choose 9/8/23 as the date to enter into this field, the UBAQ saves it as 9/7/23. In the details I can see that it is using 9/7 at 11pm as the date. The date in the dashboard comes from the MyDate combo box. Which is setup as an EpiDateTimeEditor.

This is causing a problem where the user enters the date they want, and the system records a day earlier. I think it is due to the extra time information in the field. However, I can’t figure out how to get rid of it.
I tried this approach on a suggestion from the AI.

DateTime dateValue;
if (DateTime.TryParse(MyDate.Text, out dateValue))
{
    edvCallContextBpmDataRow["Date01"] = dateValue;
}
else
{
    // Handle the case where MyDate.Text is not a valid date string
    // You can throw an exception, set a default value, or handle it in any other way.
    // I would probably assign the current system date here if the text was bad, or maybe prompt the user to check the date.
}

But this also returned the same date issue. For completeness, here is where I pull the value into my BPM:

MyDate = callContextBpmData.Date01;

And then assigning it to the new UD09 record:

ds.UD09[0].Date01 = callContextBpmData.Date01; 

This all works just fine except that the date is off. Is this the curse of DST? How can I resolve this issue?
Thanks for your time!
Nate

Do you have a timezone assigned in site or company maintenance? I think I ran into this before but I can’t remember the exact details.

1 Like

We just updated, and they added a time zone… somehere… plant settings I think? And they didn’t populate it, we had to populate it, and it fixed some stuff like that.

I think it was this one?

2 Likes

OK no idea if this will help but I have an untested theory. It sounds like some layer is treating that as a DateTime field not a date field. Date fields should not have time zones applied. I’m not sure this will work and in all fairness I’m hacking this over from a comment Olga shared with me about a simliar but different issue and could be misapplying it.

but I think the issue is the serialization of the data from the client to server and you do not what it to deal with time zones for this column. So try something like this:
ds.UD09.Columns[ā€œDate01ā€].DateTimeMode = DataSetDateTime.Unspecified;

that should tell the .net framework to not deal with time zone translations and keep your value unchanged.

Let me know if this works - I’m curious :slight_smile:

2 Likes

This seems like it is already correct for us.

This exact line didn’t work. Errored with:
CS1061 ā€˜IceColumn’ does not contain a definition for ā€˜DateTimeMode’ and no accessible extension method ā€˜DateTimeMode’ accepting a first argument of type ā€˜IceColumn’ could be found (are you missing a using directive or an assembly reference?)

Should that line of code go before or after I assign the date value to the column? I put it after in my test.

I only see it in site maintenance and it is set correctly.

When I ran into this before the problem was it was a date-time field and the timezone difference between the different sites caused it to shift to the wrong day, and unsetting the timezone fixed it. Probably not the right solution but it worked at the time.

I tried this turning off the time zone in site maint, saving, then testing a few iteration, and then resetting the time zone. This did not change the functionality. I also have been trying to use the Infragistics.Win.TimeZoneInfo to modify the datetime before I save it. I have tried lines like this (based on suggestions from AI):

Infragistics.Win.TimeZoneInfo tzi = Infragistics.Win.TimeZoneInfo.FromStandardName("Eastern Standard Time");
DateTime localDate = tzi.ToLocalTime(MyDate.DateTime.Date);
edvCallContextBpmDataRow["Date01"] = localDate;

For this code, when I choose 9/8/23, it returns 9/7 7pm. Weird right?

edvCallContextBpmDataRow["Date01"] = MyDate.DateTime.Date;

and for this code when I input 9/8, it returns 9/7 11pm.

I was originally thinking I had to update my BPM to modify the value I am pulling from the callcontext. But now I think I need to get the dashboard to output the correct date. I am not sure which is the best way to approach it, but my thinking is that I want the data correct as soon as possible. If I can get the right date in the dashboard, then it should not need any changes in the BPM.

It is a System.Data.DataSet property not a tableset property. I was thinking in terms of hte classic client.

How does that change the code you posted?

I did a MessageBox.Show on this value directly from the dashboard before BPM gets ahold of it. When I enter 9/8, it returns 9/8 12:00, just as expected. But by the time it gets pulled into the BPM the time offset takes place, returning 9/7 11pm.

And a MessageBox from my BPM shows: CallContextBpmData.Date01: <callContextBpmData.Date01/>
as 9/7 11pm.

Is your server and your client in the same time zone?

:thinking: I think our server is central. That is what is in the server address line. We are Eastern, so there certainly is an hour difference. I can’t tell where the conversion is happening based on the last post.

After thorough debugging, the conversion must happen between the dashboard customization and the BPM. Everything on the dashboard side returns the correct date, and everything on the BPM side returns the wrong date. For example, poking the call context from the dashboard, both of these calls return the correct date:

MessageBox.Show(MyDate.DateTime.Date.ToString());
edvCallContextBpmDataRow["Date01"] = MyDate.DateTime.Date;
MessageBox.Show(edvCallContextBpmDataRow["Date01"].ToString());

However, when I am in the BPM, if I pull the callcontext into a message box, it has the wrong date. If I use that callcontext to assign the date to any other variable, then obviously that variable is wrong.

I am convinced this must be due to the difference in local and server time. I just don’t know what to do about it. I worry that if I make a custom workaround (say to add a few hours to the datetime to bring it up to the date that was chosen), then Epicor will change something again and break it. There must be a ā€œcorrectā€ way to do this, right?

GPT sugggested a novel solution… that didn’t work either:

MessageBox.Show(MyDate.DateTime.Date.ToString());
// Assume formDate is the DateTime object you got from your form
DateTime formDate = MyDate.DateTime.Date;
// Create a new DateTime with only the date part and time set to midnight
DateTime myDate = new DateTime(formDate.Year, formDate.Month, formDate.Day);
// Save the date to Date01 field
edvCallContextBpmDataRow["Date01"] = myDate;
MessageBox.Show(myDate.ToString());
MessageBox.Show(edvCallContextBpmDataRow["Date01"].ToString());

The way this is built up piece by piece is a good idea, and the message boxes (in the dashboard) all return the correct date. But, as soon as the date gets into the BPM, the message boxes (in the BPM) begin returning the wrong date.

Interestingly, all three messageboxes from the dashboard returned a date with a time component. They all said 9/8/23 12:00 :thinking:

What happens if you switch your computer to the timezone of the server?

This still gives the same results. I can see the time on my PC is now 1:30 instead of 2:30, but the dashboard still returns all 9/8/23 12:00 and the BPM still returns 9/7/23 11:00. I didn’t think I could change the timezone on my PC as it should be managed by our MSP. It was pretty easy to change for a test, however it didn’t help. :frowning:

Odd @julieb just asked me to look at this exact issue she has with her. Its as you described it, everything in the BPM is fine, the UI just changes if there is a Timezone issues.

Did you ever resolve it?

Also are you running Citrix by any chance?