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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
mcquerry-dillon
Regular Visitor

#Error Involving Time Conversion

Hello,

 

I am trying to convert an integer, for example 63148, which is the amount of seconds from midnight, into a time format such as '5:36PM'.

 

I've tried using combinations of changing the box properties to Time, using a mix of conversion functions, but I still end up with an #Err in my field. I tried looking this up and couldn't find a specific use case solution for what I'm trying to do.

 

Any help would be appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @mcquerry-dillon ,

In the case of CDate expression, she can only convert a string of date type to a date, so if she converts the integer directly, an error will be reported.

Below is my table:

vxiandatmsft_1-1705461474485.png

I create Hrs , Mins , Time column

vxiandatmsft_2-1705461511739.png

The following expression might work for you:

Time =Fields!Hrs.Value & Format(Fields!Hrs.Value ,":")  & Format(Fields!Mins.Value)
Mins = Fields!NewColumn0.Value\60 - Fields!Hrs.Value*60
Hrs = Fields!NewColumn0.Value\3600
Time1 = CDate(Fields!Time.Value)

The final output is shown in the following figure:

vxiandatmsft_0-1705461388838.png

Expression examples in Power BI Report Builder - Power BI | Microsoft Learn

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @mcquerry-dillon ,

In the case of CDate expression, she can only convert a string of date type to a date, so if she converts the integer directly, an error will be reported.

Below is my table:

vxiandatmsft_1-1705461474485.png

I create Hrs , Mins , Time column

vxiandatmsft_2-1705461511739.png

The following expression might work for you:

Time =Fields!Hrs.Value & Format(Fields!Hrs.Value ,":")  & Format(Fields!Mins.Value)
Mins = Fields!NewColumn0.Value\60 - Fields!Hrs.Value*60
Hrs = Fields!NewColumn0.Value\3600
Time1 = CDate(Fields!Time.Value)

The final output is shown in the following figure:

vxiandatmsft_0-1705461388838.png

Expression examples in Power BI Report Builder - Power BI | Microsoft Learn

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

gadielsolis
Resolver III
Resolver III

Hello,

 

I would recommend the following DAX:

gadielsolis_0-1705426508762.png

If this works please mark this message as solution.

hello, 

I should clarify that I'm using the PowerBI Report Builder so this is what I'm trying to work with

mcquerrydillon_0-1705427181625.png

 

The op_time field value is an integer as mentioned earlier in seconds

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 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.