Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
ekodami
Helper I
Helper I

Converting Epoch Date fields within the import statement

Hi all, I am using a native query to import data from my source table. The date are in Epoch format but the issue is that I do not get the minutes and seconds converted during the import. Below is my sql import statement:

SELECT c1000000348 as "Epoch StartDate",DATE('1970-01-01') + (c1000000348/86400) AS "Actual Start Date",DATE('1970-01-01') + (c1000000364/86400) AS "Actual End Date" FROM t3679 WHERE C6 >= '1640995200'

Result returned is: 

ekodami_0-1784665151098.png

As you will notice, 1689601478 is converted to "2023-07-17 12:00:00 AM". I am missing minutes and seconds for the Actual Start Date and the Actual End Date.

Pls assist

Thank you

 

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

 

Three points:

1. I'm no expert in SQL but depending on the version of SQL you are using in your database, it may be that division of two integers will result in an integer. If that is the case, you may be able to convert the numerator to a float by multiplying by 1.0

 2. Your version of SQL may have builtin epoch converter you can use instead.  If it is PostgreSQL look for the to_timestamp() function.

 3. In power query M code, you could convert your `Epoch StartDate` to a real date using code similar to below

#"Add Start Date" = Table.AddColumn(#"Previous Step","Actual Start Date", each 
        #datetime(1970,1,1,0,0,0) + #duration(0,0,0,[Epoch StartDate]), type datetime)

 

View solution in original post

5 REPLIES 5
v-aatheeque
Community Support
Community Support

Hi @ekodami 

Have you had a chance to look through the responses shared earlier? If anything is still unclear, we’ll be happy to provide additional support.

ronrsnfld
Super User
Super User

 

Three points:

1. I'm no expert in SQL but depending on the version of SQL you are using in your database, it may be that division of two integers will result in an integer. If that is the case, you may be able to convert the numerator to a float by multiplying by 1.0

 2. Your version of SQL may have builtin epoch converter you can use instead.  If it is PostgreSQL look for the to_timestamp() function.

 3. In power query M code, you could convert your `Epoch StartDate` to a real date using code similar to below

#"Add Start Date" = Table.AddColumn(#"Previous Step","Actual Start Date", each 
        #datetime(1970,1,1,0,0,0) + #duration(0,0,0,[Epoch StartDate]), type datetime)

 

Hi on, thanks for the suggestion. It finally worked to give me the hh:mn values. Thanks very much

Good day, thanks for the assistance. I tried the proposed above using TO_Timestamnp function and got a fail. See below. The last option though requires that I first import the data filed, then convert wihtin Power Query.

ekodami_0-1785159341365.png

 

Glad to hear that. And yes, the PQ option converts the unix time stamp into a datetime value if you can't do it in SQL

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.