Importing excel data to MS SQL using EPPlus

Benjamin Chew 41 Reputation points
2023-02-03T02:31:52.5066667+00:00

I am writing a C# code in .Net 6 to read data from excel and save them into the database.

when reading the column with date/ date time value I realized that if the cell contains a time portion, Epplus will return the cell value as 9/1/2000 8:00:00 AM, but if the cell value only contains date, Epplus will return the value as an integer, eg: 39580.

would like to know if it is possible to standardize the return of both cell values to return in integer/double?

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,955 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,972 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,005 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Olaf Helper 45,096 Reputation points
    2023-02-03T06:20:47.2766667+00:00

    First, EPPlus isn't a Microsoft product, contact the author for support: https://github.com/JanKallman/EPPlus

    Second, Excel stores a (nuermic) value and a format information; for Excel 39580 is it a valid value for date 2008-05-12.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.