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.
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.
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"
I missed that as well. it works as supposed now 🙂
Thanks a for help. It is really appreciated.
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
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?
The formula I use (which I hope to ditch) looks like this:
Text(scheduledend, DateTimeFormat.LongDate)
Which results in this:
Monday, October 1, 2018
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"))
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.
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
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.