Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Unanswered

Dateformat in UTC in Workflow Extension

Posted on by 25

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)

7245.pastedimage1617865634343v1.png

Personalization Settings also set to UK timezeone as below

6153.pastedimage1617865739350v2.png

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans