Well, i first thought i can use the functions format date and transform them to a number to make my calculation. But i was wrong.
First i had to format them both in the same way: yyyymmdd
If both dates are in this format i can calculate the difference and based on the difference i can display a green, yellow or red icon – like a kpi indicator. So first what i did was to create three variables. One for the current date, the due date and the diff. I made them as output to compare whether the variables are really have the same output format. I realized that my currentdate comes out with 10/08/2013 09:47:33
I used substring cause the dateformat function didn’t work. With concat function i was able to put a string together which makes the format like yyyy.mm.dd – After that i can use translate and replace the “.” with an empty string.
The same i checked with due date. It output was 10.08.2013 – i only need the change the positions by using concat and substring functions. In the datediff variable i calculate the difference between duedate and current date.
Now i was able to display images based on the result of duedate. Well what i did was
if datediff > 2 display green icon
else if datediff <= 2 and datediff >=0 display yellow icon
else display red icon.
Really important notice: Check what values are on your browser – in my SharePoint Designer the returned values where different. It display always green cause he interprets the date different to my browser. Maybe an issue with german and english SharePoint Designer installation.
My result looks now like this:
Please notice that today is 08.10.2013 when i did the screenshot.
..:: I LIKE SHAREPOINT ::..