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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

How To Convert Milliseconds to Time (Day hh:mm:ss) in SQL and then in power BI?

You might have come across a situation when SQL data which is in milliseconds is shown as below in Power BI desktop as whole number and you want to convert it in Days HH : MM : SS

 

SQL.JPGPowerbidata.JPG

 

Please use below query to convert for example

"TOP (100) PERCENT
dbo.service_req.timer1,
FLOOR(dbo.service_req.timer1 / (1000 * 60 * 60 * 24)) AS Timetocloseindays, FLOOR(dbo.service_req.timer1 / (1000 * 60 * 60)) % 24 AS Timetocloseinhours,
FLOOR(dbo.service_req.timer1 / (1000 * 60)) % 60 AS Timetocloseinminutes, FLOOR(dbo.service_req.timer2 / (1000 * 60 * 60 * 24)) AS Timetorespondindays,
FLOOR(dbo.service_req.timer1 / (1000 * 60 * 60)) % 24 AS Timetorespondininhours, FLOOR(dbo.service_req.timer1 / (1000 * 60))
% 60 AS Timetorespondininminutes"

Output will be as below

SQL output.JPGOutput in Power BI.JPG

 

 

 

Status: New
Comments
v-qiuyu-msft
Community Support

Hi @mgu098,

 

Thnaks for your sharing.  Smiley Happy

 

Best Regards,

Qiuyun Yu