web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Excel Date Conversion Fails During Import (Mixed Formats)

(0) ShareShare
ReportReport
Posted on by 52

🔹 Problem Statement

 

I am importing Excel data into D365 FO using X++ (reading via range.get_Item(i, j).Value).

 

I am facing an issue where the same date field (TransDate EDT) is coming in different formats depending on the Excel file, causing conversion failures.

🔹 Sample Data

 

✅ File 1 (Working)

 
Invoice Date = 12-31-2025
 

  • Format: MM-DD-YYYY

  • Value is coming as string

    ❌ File 2 (Failing)

     
    Invoice Date = 45868
    
     

    • Format: Excel serial date

    • Value is coming as numeric (Real)

      🔹 Current Code

       
      transactiondate = range.get_Item(i, j).Value;

       

      🔹 Attempted Solution

      public static TransDate getExcelDate(anytype _value)
      {
          TransDate result;
       
          if (typeOf(_value) == Types::Real || typeOf(_value) == Types::Integer)
          {
              result = DateTimeUtil::date(
                  DateTimeUtil::addDays(DateTimeUtil::minValue(), any2int(_value) - 2)
              );
          }
          else
          {
              result = str2Date(any2Str(_value), 123);
          }
       
          return result;
      }

      ⚠️ Issue

       

      • Returning NULL for both formats

      • str2Date() fails due to format mismatch

      • Numeric conversion using DateTimeUtil::minValue() is incorrect
Categories:
I have the same question (0)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 99

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 78 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 59 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans