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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
parzival1220
Frequent Visitor

DATETIME Column

Hi there,

 

I have a datetime field in the format "20/11/2023 20:33:45". I would like to create a new column that ages this datetime value against the current system datetime value (e.g. today's date and time). Ideally, this new column will return a number of days / hours / minutes between the two dates (e.g. 1 days, 3 hours, 2 mins and 5 seconds). When I look at the options in Power Query, there doesn't seem to be one to age the date and time together, only date or time etc. 

 

Please could I ask if there is another way to calculate the whole value rather than just date or time?

 

Many thanks. 

 

Jason

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @parzival1220 

 

You can try the following methods.

Column:

Now = NOW()
Second = DATEDIFF([Datetime],[Now],SECOND)
New Time = 
var vSeconds=[Second]
var vMinutes=int( vSeconds/60)
var vRemainingSeconds=MOD(vSeconds, 60)
var vHours=INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
var vDays=INT(vHours/24)
var vRemainingHours=MOD(vHours,24)
return
  vDays&" Days & "&
  vRemainingHours&" Hours & "&
  vRemainingMinutes&" Minutes & "& 
  ROUND(vRemainingSeconds,0)& " Seconds"

vzhangti_0-1700717214467.png

Is this the result you expect? Please see the attached document.

 

Best Regards,

Community Support Team _Charlotte

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

HotChilli
Community Champion
Community Champion

On the 'Add Column' tab, If you select both columns, you can use the Time section (it will activate a Subtract menu item).  This will subtract one column from the other and give you a duration.  This is when the fun starts.

You can use duration in Power Query but DAX doesn't know how to deal with it in a way that you probably want.  There are lots of functions to give you minutes from a duration and (on the forum and the web) you will find ways to get that as a text field in days,hrs, minutes, seconds

Apologies for the late reply and thank you for the suggestions. I will have a play with Power Query and report back 😀.

 

Thanks again.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.