Resulting NaN when calculating between two dates

Copper Contributor

Hi, Everyone

Stay safe.

 

JunHo_KIM_0-1585355600151.png

I am using SharePoint Online lists.

 

1. The 'DueDate' column is manually typed in date&time format.

2. The columns 'TODAY2' and 'TODAY' are automatically generated by JSON code.

 

I have two questions.

(1) I would like to calculate days left in column 'DAY2' between 'DueDate' & 'TODAY2' using JSON. However, when I do that it returns 'NaN' error. So, I tested using 'Created' column instead of 'DueDate' and it works!!! I thought it was because of format difference, so I manually typed in same format in column 'Remark', but the result was the same error.

 

(2) I do not want to see decimal figures in 'DAY2'. I tried to format from 'Automatic' to '0' in column setting, but did not help.

 

FYI, the JSON codes applied in 'DAY2' are as below;

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": {
"operator": "/",
"operands": [
{
"operator": "-",
"operands": [
{
"operator": "Number()",
"operands": [
"@now"
]
},
{
"operator": "Number()",
"operands": [
"[$Created]"
]
}
]
},
86400000
]
}
}

2 Replies
Hi,
I do see some empty values on the 'DueDate' column, are you sure that the column will have no empty values, because if the created works then your column should unless there is an empty value.

@Sudharsan K 

 

Hi,

Hope you are doing well.

 

Do you mean space between the column name 'DueDate' or dates in the column?

(1) If you are talking about 'DueDate', 100% sure there is no space.

(2) If you are talking about the dates in the column, the actual values are yyyy-MM-dd without space. The symbols are just JSON formatted ones. I was also wondering if it could fail my expectation. So, I tested using the column '계약 시작일' which did not have JSON. The result was the same.

 

Thanks for your help.