<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to convert DATE/TIME Column to duration? in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/2815235#M26580</link>
    <description>&lt;P&gt;You cannot automatically convert a Time column to a duration since a Time is a single point in time so it has no duration. But in your case it sounds like something like 05:00 should be a duration of 5 hours. So one way to do this is calculate the duration from midnight to the specified time. You can do this by subtracting a time of "00:00" from your current time column (subtracting one time from another returns a duration)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you click on "Add Column" in the ribbon then choose the "Custom Column" optoin and enter a formula like the following it will return a duration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[YourTimeColumn] - Time.FromText("00:00:00")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Oct 2022 22:27:09 GMT</pubDate>
    <dc:creator>d_gosbell</dc:creator>
    <dc:date>2022-10-03T22:27:09Z</dc:date>
    <item>
      <title>How to convert DATE/TIME Column to duration?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/2814720#M26575</link>
      <description>&lt;P&gt;Hello Everyone,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I linked an external database to access and then linked from access to PowerBI.&lt;BR /&gt;I am trying to create a dashboard to extract worked hours, but when doing the link described above, the worked hours came as DATE/TIME, not duration, so PowerBI does not sum the hours correctly, I need to convert DATE/TIME to duration but didn't find any solution to make this.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I already tried to do as bellow&amp;nbsp;&lt;BR /&gt;EDIT QUERY / Transform Collum / Transform Time only&amp;nbsp; = The time came i.e. 5:00:00.&amp;nbsp;&lt;BR /&gt;Also tried to convert as Duration, but PowerBI just give me a message of error, not allowing to convert it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can someone help me?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 17:59:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/2814720#M26575</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-03T17:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert DATE/TIME Column to duration?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/2814763#M26576</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Chelsie-Eiden-s-Duration/m-p/793639#M389" target="_blank"&gt;Chelsie Eiden's Duration - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 18:22:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/2814763#M26576</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2022-10-03T18:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert DATE/TIME Column to duration?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/2815235#M26580</link>
      <description>&lt;P&gt;You cannot automatically convert a Time column to a duration since a Time is a single point in time so it has no duration. But in your case it sounds like something like 05:00 should be a duration of 5 hours. So one way to do this is calculate the duration from midnight to the specified time. You can do this by subtracting a time of "00:00" from your current time column (subtracting one time from another returns a duration)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you click on "Add Column" in the ribbon then choose the "Custom Column" optoin and enter a formula like the following it will return a duration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[YourTimeColumn] - Time.FromText("00:00:00")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 22:27:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/2815235#M26580</guid>
      <dc:creator>d_gosbell</dc:creator>
      <dc:date>2022-10-03T22:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert DATE/TIME Column to duration?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/3616130#M32252</link>
      <description>worked perfectly - thank you</description>
      <pubDate>Thu, 04 Jan 2024 17:50:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/3616130#M32252</guid>
      <dc:creator>searl</dc:creator>
      <dc:date>2024-01-04T17:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert DATE/TIME Column to duration?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/4627033#M40115</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="109790" data-lia-user-login="d_gosbell" class="lia-mention lia-mention-user"&gt;d_gosbell&lt;/a&gt;&amp;nbsp; it dosn't work if duration if longer than 24 hr. Is there any solution to this case?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 08:24:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/4627033#M40115</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-03-27T08:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert DATE/TIME Column to duration?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/4628408#M40121</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Anonymous&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="109790" data-lia-user-login="d_gosbell" class="lia-mention lia-mention-user"&gt;d_gosbell&lt;/a&gt;&amp;nbsp; it dosn't work if duration if longer than 24 hr. Is there any solution to this case?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It depends what format your input is in. The original question here was about converting a time column to a duration and times cannot have more than 24 hrs. So you either have a text value or maybe a datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a text value something like "27:35:12" in your data then you can use a function like the following example to convert the format into the following format ddd.hh:mm:ss which is what power query uses for durations longer than 24 hrs&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;let
    fixDuration = (input as text) =&amp;gt;
        let
            parts = Splitter.SplitTextByDelimiter(":")(input),
            hour = Number.FromText(parts{0}),
            days = Number.RoundDown( hour / 24),
            newHour = Number.ToText( Number.Mod(hour, 24)),
            newValue = if days &amp;gt; 0 
                then Duration.FromText(Number.ToText(days) &amp;amp; "." &amp;amp; newHour &amp;amp; ":" &amp;amp; parts{1} &amp;amp; ":" &amp;amp; parts{2})  
                else Duration.FromText(input)
        in
            newValue,
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjK3Mja1MjRSitWJVjLUM7YyNrMyNFSKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TextColumn = _t]),
    #"Added Custom" = Table.AddColumn(Source, "DurationColumn", each fixDuration([TextColumn]))
in
    #"Added Custom"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if your data is already in ddd.hh:mm:ss format you can just use Duration.FromText to convert the type&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 00:55:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-convert-DATE-TIME-Column-to-duration/m-p/4628408#M40121</guid>
      <dc:creator>d_gosbell</dc:creator>
      <dc:date>2025-03-28T00:55:54Z</dc:date>
    </item>
  </channel>
</rss>

