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
patelvatsal1621
Frequent Visitor

Converting SAP or Unix time stamp (with Micro-seconds)

I'm trying to convert the dates pulled out of SAP in M code to make data ready for reporting. Attached image will show the actual date format which is having micro seconds as well.

 

Is there a way I can convert the below values to dates in M code:

 

DateFormat -- 2021-07-14 155335.pngPower BI Dates To convert.png

 

One of the solution was to convert the number into date using a formula, please refer below link:

 

Solved: Converting SAP or Unix time stamp - Microsoft Power BI Community

 

This is not working for me.  Can someone help?

 

Feel free to let me know if you need further info.

 

 

2 ACCEPTED SOLUTIONS
watkinnc
Super User
Super User

So let's day your SAP/UNIX datetime column is named SAPTime. If your most recent step is "LastStep", then in the formula bar, you would type:

 

= Table.TransformColumns(LastStep, {{"SAPTime", each #datetime(1970,1,1,0,0,0) + #duration(0,0,0,[SAPTime])}})

 

This says take the duration of these seconds, and add that to 1/1/1970 for each value in the SAPTime column.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

View solution in original post

V-pazhen-msft
Community Support
Community Support

@patelvatsal1621 

You cannot have seconds in decimals in date time type, You can just split the microseconds to another column, then you are able to change the date column to date type.

 

Vpazhenmsft_1-1626658976583.png

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
V-pazhen-msft
Community Support
Community Support

@patelvatsal1621 

You cannot have seconds in decimals in date time type, You can just split the microseconds to another column, then you are able to change the date column to date type.

 

Vpazhenmsft_1-1626658976583.png

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

watkinnc
Super User
Super User

So let's day your SAP/UNIX datetime column is named SAPTime. If your most recent step is "LastStep", then in the formula bar, you would type:

 

= Table.TransformColumns(LastStep, {{"SAPTime", each #datetime(1970,1,1,0,0,0) + #duration(0,0,0,[SAPTime])}})

 

This says take the duration of these seconds, and add that to 1/1/1970 for each value in the SAPTime column.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Thank you so much. It worked!

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.

Top Solution Authors
Top Kudoed Authors