Skip to content


Tech Tuesday: Working with Date and Time Fields in Integration between Microsoft Dynamics CRM and Microsoft Dynamics GP using SmartConnect

Today’s Tech Tuesday article comes right from the trenches of working in the world of integration. In this article we are going to focus on date fields from Microsoft Dynamics CRM.

Oftentimes when customers need to transform date fields from one format to another they will just use the standard SmartConnect Date Calculation (under Additional Fields in the mapping).

This will normally allow you to transform a date field from any format to any format. In the case of this specific customer we ran into two unique issues.

1) The first hurdle was that sometimes the date field coming from Microsoft Dynamics CRM would be NULL. This presents challenges as you have to make assumptions on how you handle NULLS. 

2) The second challenge was that we had multiple regions involved. In this specific example, we had Microsoft Dynamics CRM Online (hosted in a US locale) and Microsoft Dynamics GP on premise in the UK.

This customer had a Dynamics GP field that needed that date value along with another Extender window that needed the date value. What we were able to do to accomplish this task was to provide a calculated field to meet the criteria for both scenarios. Here is the calculated field that was used below in VB.NET form:

‘Use the date field from your CRM Entity below
Dim dateString as string = _CUSTOMENTITY_STARTDATE 
Dim provider as System.Globalization.CultureInfo = System.Globalization.CultureInfo.InvariantCulture
‘substitute the “en-US” below with the locale of the source data
Provider = New System.Globalization.CultureInfo(“en-US”)
‘Handle NULL/Blank value of date/datetime field 
if dateString =”” then
     return “1900-01-01”
     ‘Convert the datestring provided to a date field in locale, then convert to desired locale
     return (Convert.ToDateTime(dateString,provider)).ToString(“yyyy-MM-dd”)

end if
In this script we are using an interesting .NET feature. The CultureInfo class allows us to determine the locale of the date format. This in turn can be used to convert the dateString from Microsoft Dynamics CRM to the format of any locale. In our specific example we converted a US format date into the format that most of the world uses (in this specific instance, the UK). Additionally, we simply indicated that a blank value would return a standard date in the format that Microsoft Dynamics GP likes.
This script could be used to change any date/datetime field into a format suitable for Microsoft Dynamics CRM or Microsoft Dynamics GP.
Hope this helps you with any date calculation issues you may be trying to solve.
Chris Dew

Want more information on SmartConnect and the features it offers? Please contact for more information!

1 Comment

  1. Nannette Belcher on January 17, 2018 at 12:21 pm

    You wouldn’t happen to have this code lying around in C#…. would you?

Leave a Comment


Accessing Historical Dynamics GP Data in NetSuite: Using Popdock
Popdock's Top 10 New Features
New Webinar: Getting Started with Matrix Reporting in Popdock
Tech Tuesday: Popdock User Security in D365 Business Central
Popdock Data Lake Upload Tool for Dynamics NAV Data - FREE TRAINING


2016 SmartConnect Integration Bootcamps
Tech Tues: Automatically refreshing Pivot Tables in Excel Refreshable Reports
Happy Thanksgiving from the eOne team!
2017 SmartConnect Integration Bootcamps
New Releases of Extender and SmartList Builder



Business Central CRM D365 Business Central Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News error Error Message Events Excel Excel Report Builder Extender Flexicoder GP integration Map Microsoft dynamics crm Microsoft Dynamics GP Navigation List Builder Office Relationships Partner All Hands Call Popdock promotions release SalesForce SmartConnect SmartConnect Bootcamp SmartConnect Maps SmartConnect Office Hours SmartList SmartList Builder SmartPost SmartView SQL Tech Tuesday Templates training Zendesk

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.