JSON Format sharepoint list format to calculate days left before expiration date or due date

Princess "Abby" Amante 21 Reputation points
2020-09-30T21:28:51.5+00:00

hello,

i have a column in sharepoint list called "Expiration Date" i would like to get the number of days left before the expiration date. im using the JSON format below.
the JSON format is working but i would to get a round number in return without decimal points.

{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"elmType": "div",
"txtContent": {
"operator": "/",
"operands": [
{
"operator": "-",
"operands": [
{
"operator": "Number()",
"operands": [
"@now "
]
},
{
"operator": "Number()",
"operands": [
"[$ExpirationDate]"
]
}
]
},
86400000
]
}
}

29503-image.png

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,249 questions
0 comments No comments
{count} votes

Accepted answer
  1. ChelseaWu-MSFT 6,316 Reputation points
    2020-10-01T06:17:13.61+00:00

    You can use floor() operation to return the largest integer less than or equal to the calculated value.

    {  
        "elmType": "div",  
        "txtContent": {  
            "operator": "floor",  
            "operands": [  
                {  
                    "operator": "/",  
                    "operands": [  
                        {  
                            "operator": "-",  
                            "operands": [  
                                "=Number('@now')",  
                                "=Number('[$ExpirationDate]')"  
                            ]  
                        },  
                        86400000  
                    ]  
                }  
            ]  
        }  
    }  
    

    Here is the test result:

    29575-screenshot-2020-10-01-141239.png

    Reference: Use column formatting to customize SharePoint.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    **Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. **


0 additional answers

Sort by: Most helpful