We have recently moved Dynamics 2016(On Prem) to D365 Online. D365 Online Instance is in UK region, below is sysem settings image having everything setup in UK format (Date,Time,Currency etc)
Personalization Settings also set to UK timezeone as below
We have workflow extension which is working fine in 2016 since 3 yrs but in Online version DateTime format is retrieved as UTC whiich breaks our logice. In UK its daylight saving.
Below is the code which uses passed parameter to code as well as direct retrieval from entity, no matter what i do it always return dateformat in UTC. Field type in System is Date Only with Behaviosr UserLocal. Raised ticket with Microsoft but no luck yet. If anyone has come across this sort of issue do ping. We tried all possible options, changing timezone to anything isn't an option because system has dependency on Time.
//Code debugging for date formats
//This need to be removed once fixed
var sb = new StringBuilder();
sb.AppendLine( string.Format("Input Parameters {0} -- {1}", fromDate, toDate));
var frmDate = Convert.ToDateTime(fromDate, new CultureInfo("en-GB"));
var tDate = Convert.ToDateTime(toDate, new CultureInfo("en-GB"));
sb.AppendLine(string.Format("Converted using local Culture{0} -- {1}", frmDate, tDate));
sb.AppendLine(string.Format("Converted using localtime {0} -- {1}", fromDate.ToLocalTime(), tDate.ToLocalTime()));
var colSet = new ColumnSet(new String[] { "new_fromdate", "new_todate", });
//Retrieve directly from entity
var shobj = organizationService.Retrieve("entityName", holidayRange.Id, colSet);
sb.AppendLine("Retrieved from Entity Dates");
var fdate = shobj.GetAttributeValue<DateTime>("new_fromdate");
var tdate = shobj.GetAttributeValue<DateTime>("new_todate");
sb.AppendLine(string.Format("From Date ToLocal Time and To Date to ToLocal time{0} -- {1}", fdate.ToLocalTime(), tdate.ToLocalTime()));
sb.AppendLine(string.Format("From Date ToUniversal Time and To Date to Universal time{0} -- {1}", fdate.ToUniversalTime(), tdate.ToUniversalTime()));
var task = new Entity("task");
task["subject"] = "Dates";
task["description"] = sb.ToString();
organizationService.Create(task);
//End Code Debugging to test date formats
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156