title: Calculate "age" from date/time table
body: <p>I have a Date/Time column in format &quot;13.10.2020 06:08:43&quot; and I need to calculate the &quot;age&quot; from current time. Output should be like from given example: &quot;4h&quot; since its 10:08 atm - Date/Time column was 4h ago. I need this to be in M language to use in visual studio 2019.</p>
  <p>I used:</p>
  <pre><code>let
  
          Source = Sql.Database(&quot;xxxx&quot;, &quot;xxxxx&quot;, [Query=&quot;SELECT#(lf)#(tab)storeid as 'Shop'#(lf)#(tab), concat('SCO', posnr) as POS#(lf)#(tab),  concat(datediff(hour,[LastTransactionDate]#(lf)#(tab), CURRENT_TIMESTAMP),' h') as 'Age'#(lf)#(tab), POSIPaddress as 'IP'#(lf)#(tab),[PosNr]#(lf)    ,[AdapterPosOrGroupId]#(lf)    ,[UpdatedOn]#(lf)    ,[LastTransactionDate]#(lf)    ,[LastStartDate]#(lf)    ,[Open]#(lf)    ,[Locked]#(lf)    ,[CashDisabled]#(lf)    ,[IsCashEnabled]#(lf)    ,[CashDevicesTraficLight]#(lf)    ,[POSIPAddress]#(lf)    ,[ScoPosServiceVersion]#(lf)    ,[WinScoVersion]#(lf)    ,[StoreType]#(lf)FROM [LaneEventDatabase ].[dbo].[POS.LaneCurrentState]&quot;]),
          #&quot;Added Conditional Column&quot; = Table.AddColumn(Source, &quot;Custom&quot;, each if [CashDevicesTraficLight] = &quot;green&quot; then 1 else if [CashDevicesTraficLight] = &quot;yellow&quot; then 2 else if [CashDevicesTraficLight] = &quot;red&quot; then 3 else 4),
          #&quot;Changed Type&quot; = Table.TransformColumnTypes(#&quot;Added Conditional Column&quot;,{{&quot;Custom&quot;, type number}})
      in
          #&quot;Changed Type&quot;
  </code></pre>
  <p>which works just great but visual studio doesnt like the way source is handled and while deploying gives me error:</p>
  <pre><code>Failed to save modifications to the server. Error returned: 'An M partition uses a data function which results in access to a data source different from those defined in the model.
  
  '.
  </code></pre>