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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Super User
Super User

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.