Hi @Harry N Nomikos,
Thank you for your reply.
I apologize that my previous reply was faulty and didn't address your question.
Here are my results after testing.
1.Go Live date column
You can replace the code below:
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-15"
},
"txtContent": "= 'Go Live Date:' + toLocaleDateString([$GoLiveDate])"
}
2.Days till Go Live column
I asked my colleague how to calculate the countdown time from a given date to today, and then realized that my previous method was wrong, and that the countdown date is dynamically unchanging.
Actually, this column need not be a calculated column (and if you are a calculated column you don't have to modify it, the value of the column is not used in JSON formatting), I used the following JSON code to implement the calculation of the countdown days from the date to today for Go Live date column:
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-15"
},
"children": [
{
"elmType": "span",
"txtContent": "=if (Number([$GoLiveDate]) == 0, 'Days till Go Live', 'Days till Go Live:')"
},
{
"elmType": "span",
"txtContent": "=if (Number([$GoLiveDate]) == 0, '',floor((Number([$GoLiveDate])-Number(@now))/(1000*60*60*24)))"
}
]
}
For this floor(), I have some instructions:
1.floor((Number([$GoLiveDate])-Number(@now))/(10006060*24)) will take the difference between dates, divide it by duration of a day, and round the final number down to a full number.
For example: My test today was September 14, 2023 at 3:14pm and the Go Live Date was September 16, 2023. The actual number of days they are apart is: 1.8849 days, but floor() will modify that to 1 day.
If you think the time error is a bit large, then you can add another day to the end.
floor((Number([$GoLiveDate])-Number(@now))/(1000*60*60*24))+1
Here is the result in my side (I just changed the color of the font):
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.