Forum Discussion

NathanAlex's avatar
NathanAlex
Copper Contributor
Aug 04, 2023

Adding 1 everyday to a sharepoint list column

I'm trying to add 1 to a column everyday in sharepoint lists. We have a column called "Hire Instated" and another column called "Days in Hire".    Essentially we need the days in hire to increase e...
  • SvenSieverding's avatar
    Aug 04, 2023

    Hi NathanAlex,

    do you really want to have a column that contains the number of days since the hire date or do you just want to display the number of days?

    You can do the latter quite easily, if you apply the following JSON formatting on your "Hire Instated" column:

     

    {
        "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
        "elmType": "div",
        "style": {
            "display": "block"
        },
        "children": [
            {
                "elmType": "div",
                "txtContent": "=@currentField.displayValue"
            },
            {
                "elmType": "div",
                "txtContent": "=floor((Number(Date((getMonth(@now)+1)+'.'+getDate(@now)+'.'+getYear(@now)))-Number(@currentField))/(60*60*24*1000))+' day(s)'"
            }
        ]
    }

     

    This would look like this


    Just select the little arrow down next to your column name and select "Column Settings"->"Format this column". Then switch to "Advanced mode" and paste that JSON into the editor.

    Best Regards,
    Sven

Resources