Power Query; Convert Time Stamp to Date Time


Power Query has number of Date and Time functions that convert values to date and time. However I haven’t found a function that converts a timestamp value. Fortunately it is easy to calculate a date time from a timestamp value. In this post I’ll explain an easy way of converting timestamp to date time. To Learn more about Power Query read Power BI online book; from Rookie to Rock Star.

What is Timestamp

Timestamp is a whole number value, which is number of seconds from date 1970-01-01 00:00:00. For example; timestamp 100 means 1970-01-01 00:01:40, or timestamp 86400 means 1970-01-02 00:00:00. So the calculation is easy; We have to add timestamp as seconds to the date/time 1970-01-01 00:00:00.

Power Query Convert Timestamp to Date Time

Once we know what is definition of timestamp, and how to calculate date/time from it; easily we can use #duration(0,0,0,<timestamp value>) to show duration in seconds, and add it to the #datetime(1970,1,1,0,0,0) which is date time 1970-01-01 00:00:00.

So as a result, here is the code to convert timestamp to date time;


above query will respond  11/11/2014 9:12:45 AM.

Please note that you have to replace the 1415697165 number with the field name containing timestamp values, or with your static timestamp value in the query.



Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
Reza Rad
Trainer, Consultant, Mentor
Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for nine continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.
He wrote some books on MS SQL BI and also is writing some others, He was also an active member on online technical forums such as MSDN and Experts-Exchange, and was a moderator of MSDN SQL Server forums, and is an MCP, MCSE, and MCITP of BI. He is the leader of the New Zealand Business Intelligence users group. He is also the author of very popular book Power BI from Rookie to Rock Star, which is free with more than 1700 pages of content and the Power BI Pro Architecture published by Apress.
He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
Reza’s passion is to help you find the best data solution, he is Data enthusiast.

3 thoughts on “Power Query; Convert Time Stamp to Date Time

Leave a Reply

%d bloggers like this: