Post

3 followers Follow
0
Avatar

calculate If older than

I need to "flag" an item with a category in an app, if the date field is older than 2 months of the creation date - how would I go about that? 

Jakob Rosenfeldt

Please sign in to leave a comment.

11 comments

0
Avatar

Hi Jakob,

Are you saying you want to update a category field to a different status/category when the date field is older than 2 month of the item creation date?  If so you will need to us Globiflow for that, its not possible via a calculation.  I would suggest you post on their forum if you have Globiflow.  If you do not have Globiflow then it may be possible to create a banner that highlights if it is older, I'm just not sure how to calculate based on the inbuilt creation date, you may need to fill in a date field as creation date (or have a flow add it if you are on a plus plan).  If you want some instructions on the latter I would be happy to help.

Kent

Kent Watson 0 votes
Comment actions Permalink
0
Avatar

The date field it calculates from is automatically set when the item is created via flows. 

So some instructions would be nice :) 

thanks 

Jakob Rosenfeldt 0 votes
Comment actions Permalink
0
Avatar

Hi Jakob,

As mentioned this is not going to change a status, however you can use the following to create a banner

 

var txt = (@Date.getTime()- @Created On.getTime()) > 5270400000 ? "ALERT" : "OK"  //you can change text here
var col = (@Date.getTime() - @Created On.getTime()) > 5270400000 ? "F10714" : "677BDE" //you can change the HTML colour codes here
write = "![](http://dummyimage.com/" + 710 + "x" + 100 + "/" + col + "/" + "000000" + ".png&text=" + txt.toUpperCase() + ")"

 

This will set an ALERT banner if the difference in the created date is greater than 61 days (5270400000 milliseconds)

This uses the dummyimage.com website

Kent Watson 0 votes
Comment actions Permalink
0
Avatar

So the @date.gettime is the manual date field - right? 

@oprettet = @created on

var txt = (@Dato for arrangement.getTime()- @Oprettet.getTime()) > 5270400000 ? "ALERT" : "OK"
var col = (@Dato for arrangement.getTime() - @Oprettet.getTime()) > 5270400000 ? "F10714" : "677BDE"
write = "![](https://dummyimage.com" + 710 + "x" + 100 + "/" + col + "/" + "000000" + ".png&text=" + txt.toUpperCase() + ")"

 

However an item with the date 5/8-2016 gets the OK image. 

Have I done somthing wrong? 

Jakob Rosenfeldt 0 votes
Comment actions Permalink
0
Avatar

Yes @Date.getTime() is the manual date

I think I misunderstood the order of the dates

instead of 

@Date.getTime() - @Created On.getTime()

use

@Created On.getTime() - @Date.getTime()
Kent Watson 0 votes
Comment actions Permalink
0
Avatar

OK. Made the correction and now it seems to work, however I ger the "broken image link"-icon where it before showed "OK"

 

var txt = (@Oprettet.getTime()- @Dato for arrangement.getTime()) > 5270400000 ? "ALERT" : "OK"
var col = (@Oprettet.getTime()- @Dato for arrangement.getTime()) > 5270400000 ? "F10714" : "677BDE"
write = "![](https://dummyimage.com" + 710 + "x" + 100 + "/" + col + "/" + "000000" + ".png&text=" + txt.toUpperCase() + ")"

 

Jakob Rosenfeldt 0 votes
Comment actions Permalink
0
Avatar

brilliant! 

Works as a charm! 

 

Thanks a lot! 

Jakob Rosenfeldt 0 votes
Comment actions Permalink
1
Avatar

Hi Guys,

FWIW - just 2 Tips:
1. The nicer banner/buttons you get here: dabuttonfactory.com
2. The whole calculation can be shorter:

61 >= moment(@date).diff(moment(@Created on),"h")/24 ? x = {"col":"F10714","text":"ALERT"} : x = {"col":"677BDE","text":"OK"};
"![]; (https://dabuttonfactory.com/button.png?t=" + x.text + "&f=Calibri-Bold&ts=24&tc=fff&tshs=1&tshc=000&hp=20&vp=8&c=5&bgt=unicolored&bgc=" + x.col + ")"

This is the original I got from dabutton: https://dabuttonfactory.com/button.png?t=Your+Text&f=Calibri-Bold&ts=24&tc=fff&tshs=1&tshc=000&hp=20&vp=8&c=5&bgt=unicolored&bgc=3d85c6
Just remove "Your+Text" and the color code by the variables. If you wnat the banner wider change hp=, if higher vp=

Rainer



Rainer Grabowski 1 vote
Comment actions Permalink
0
Avatar

Thanks @Rainer, love your work as always

dabuttonfactory.com is terrific

and I love the simplicity of your calc.  I'll have to do some work with moment, diff and JS objects I see

Kent Watson 0 votes
Comment actions Permalink