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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Converting timestamp fromI to Date/Time

How can I convert this data to a date, in our database I got this timestamp 1557280403.  It is from a SQL server. 

 

help wanted 

2 ACCEPTED SOLUTIONS
blopez11
Resident Rockstar
Resident Rockstar

If the timestamp is seconds since 1/1/1970, you can use the use the following function, call it GetDateTimeFromSeconds, then add a step in your query to create a column, calling this function, and passing in your timestamp

 

I can't take credit for this, got this from another helpful contributor to the community

 

Hope it helps,

//
// ...This function takes in seconds from epoch and returns a value in datetimezone (UTC)
//
let
Source = (seconds as number) =>
let
Result = #datetimezone(1970, 1, 1, 0, 0, 0, 0, 0) + #duration(0, 0, 0, seconds)
in
Result
in
Source

View solution in original post

Anonymous
Not applicable

Hi 

Thank you for the reply. 

Can to translate it to DAX. (sorry but I am very new in this)

View solution in original post

6 REPLIES 6
blopez11
Resident Rockstar
Resident Rockstar

If the timestamp is seconds since 1/1/1970, you can use the use the following function, call it GetDateTimeFromSeconds, then add a step in your query to create a column, calling this function, and passing in your timestamp

 

I can't take credit for this, got this from another helpful contributor to the community

 

Hope it helps,

//
// ...This function takes in seconds from epoch and returns a value in datetimezone (UTC)
//
let
Source = (seconds as number) =>
let
Result = #datetimezone(1970, 1, 1, 0, 0, 0, 0, 0) + #duration(0, 0, 0, seconds)
in
Result
in
Source

Anonymous
Not applicable

Hi 

I got it works. thanks very much. 

Anonymous
Not applicable

Hi 

Thank you for the reply. 

But can you translate it into DAX. (sorry but I am very new in this)

 

 

Anonymous
Not applicable

Hi 

Thank you for the reply. 

Can to translate it to DAX. (sorry but I am very new in this)

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

You can use M to do it, as below

 

#datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, 1557280403)


Hope it helps
Mariusz

Anonymous
Not applicable

Hi 

I got it works. thanks you very much. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.