3

I have a list I am displaying with the "modern" experience that includes a column of the Hyperlink type that links to a status report. The description of the Hyperlink is the date that the status report was last updated (manually entered). Can I do conditional formatting on this column based on the Hyperlink description? I would like to convert the description string into a Date and compare it to the current date and format the text red if it is more than 2 weeks old.

Any help would be much appreciated!

0

Comparison and date operations are only possible if the field is a date object (i.e your column type has to be date). In your case, ideally you would need to add the millisecond equivalent of 2 weeks onto the "@now" reference. Nonetheless, I found a workaround that you might be able to rely on.

You will essentially be comparing the date string you have now against a date string that is 2 weeks in the future. As such, you need to manually update the date that is two weeks into the future. Here is a quick JSON reference that I came up with. I haven't tested its validity but it should provide the basis of a good start.

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "debugMode": true, "txtContent": "@currentField", "style": { "color": "=if @currentField == ' enter date that is two weeks in the future' , '#ff0000', '')" } }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.