web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Format date-time as on...
Power Apps
Answered

Format date-time as on this forum

(1) ShareShare
ReportReport
Posted on by 306

Is it possible to format date/times as they are shown on this forum? E.g. 20 minutes ago, yesterday, Sunday etc.

As far as I can see, there's no out-of-the-box formatting to do this. This way of showing a date and time is much more userfriendly in my opinion than using ShortDate24, LongDate24 etc. 

 

Has anyone played around with this? Any input is appreciated. 

 

Capture.PNG

Categories:
I have the same question (0)
  • Verified answer
    Fakhri Profile Picture
    72 on at

    Hi @NielsL

     

    I had tried something similar, but not quite the same. But I think it might help point you to the right direction 

     

    If( DateDiff((Created),NowTime,Minutes)<60 , Concatenate(Text(DateDiff((Created),NowTime,Minutes))," mins ago"),
      DateDiff((Created),NowTime,Hours)<=24 , Concatenate(Text(DateDiff((Created),NowTime,Hours))," hours ago"),
      DateDiff((Created),NowTime,Days)<=31 , Concatenate(Text(DateDiff((Created),NowTime,Days))," days ago"),
      DateDiff((Created),NowTime,Months)<=12 , Concatenate(Text(DateDiff((Created),NowTime,Months))," months ago"),
      Concatenate(Text(DateDiff((Created),NowTime,Years))," years ago"))

     

    You need to change the "Created" date to your data date. I'll give a bit of thinkering maybe some adjustment and you will get the result you want.
       

  • Nielf Profile Picture
    306 on at

    @Fakhri, thanks. 

     

    That was exactly what I was looking for. 

  • Fakhri Profile Picture
    72 on at

    Hi @NielsL

     

    Glad that help you. Anyways if you want similar result to the one you post, try this one instead:

     

    If( DateDiff((Created),NowTime,Minutes)<60 , Concatenate(Text(DateDiff((Created),NowTime,Minutes))," mins ago"),
      DateDiff((Created),NowTime,Hours)<=24 , Concatenate(Text(DateDiff((Created),NowTime,Hours))," hours ago"),
      DateDiff((Created),NowTime,Days)<=31 ,Text(Created,"[$-en-US]dddd"),
      DateDiff((Created),NowTime,Months)<=12 , Text(Created),
      Concatenate(Text(DateDiff((Created),NowTime,Years))," years ago"))
       

    The only difference is, when the date diff is more than 1 day then it will display the day of the week, if it is more than a week then it will just put the actual date. You have a nice day mate 

  • Nielf Profile Picture
    306 on at

    @Fakhri

     

    Can you show some screenshots of your working formula in PowerApps?

     

    I'm getting some errors saying that Name isn't available. I have updated the formula with my date input so that doesn't seem to be the problem. 

     

    It's probably just me doing it wrong. 

  • Fakhri Profile Picture
    72 on at

    Hi again @NielsL

     I forgot I used a variable "NowTime". You can replace it with Now(). Not sure why I created that variable. Maybe I was intending to use it again in another formula. But once you change it to Now(), should run fine.

     

    If( DateDiff((Created),Now(),Minutes)<60 , Concatenate(Text(DateDiff((Created),Now(),Minutes))," mins ago"),
      DateDiff((Created),Now(),Hours)<=24 , Concatenate(Text(DateDiff((Created),Now(),Hours))," hours ago"),
      DateDiff((Created),Now(),Days)<=31 , Text(Created),,
      DateDiff((Created),Now(),Months)<=12 , Concatenate(Text(DateDiff((Created),Now(),Months))," months ago"),
      Concatenate(Text(DateDiff((Created),Now(),Years))," years ago"))

     

    Posting date indicator.png

  • Nielf Profile Picture
    306 on at

    @Fakhri

     

    Just to be sure: The formula is to be used on Text property, right? 

     

    I've updated the formula to be:

    If( DateDiff((scheduledend),Now(),Minutes)<60 , Concatenate(Text(DateDiff((scheduledend),Now(),Minutes))," mins ago"),
     DateDiff((scheduledend),Now(),Hours)<=24 , Concatenate(Text(DateDiff((scheduledend),Now(),Hours))," hours ago"),
     DateDiff((scheduledend),Now(),Days)<=31 , Text(scheduledend),,
     DateDiff((scheduledend),Now(),Months)<=12 , Concatenate(Text(DateDiff((scheduledend),Now(),Months))," months ago"),
     Concatenate(Text(DateDiff((scheduledend),Now(),Years))," years ago"))

    But that returns a series of errors. Could this be a copy/paste error?

    2.PNG

    The formula I use (which I hope to ditch) looks like this:

    Text(scheduledend, DateTimeFormat.LongDate)

    Which results in this:

    Monday, October 1, 2018

     

  • Fakhri Profile Picture
    72 on at

    Sorry @NielsL

    It seems one of the line of code was wrong. There is an extra "," the third line. Try eliminating that 1st and then we see whether that resolves the issue

  • Nielf Profile Picture
    306 on at

    @Fakhri

     

    I missed that as well. it works as supposed now 🙂 

     

    Thanks a for help. It is really appreciated. 

  • Fakhri Profile Picture
    72 on at

    Hi @NielsL

     

    Glad it worked just fine . Sorry for the mistake.

     

    Anyways hopefully you can make this even better since the formula I gave you isn't the best way, since not every month has 31 days in it. But the method used by our forum is actually quite smart as anything more than a week will return a date instead of my original formula which returns " months ago"

     

     

  • Nielf Profile Picture
    306 on at

    @Fakhri

     

    I'll see if I can make improvements to the formula. E.g. it would be cool to add something like "last week", "two weeks ago" etc. 

     

    It's one of the small things, but I really think something like this improves the user experience. Users of the apps are used to seeing dates formatted like this on social media like LinkedIn, Twitter, Facebook etc.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard