Forum Discussion

SP1's avatar
SP1
Copper Contributor
Aug 06, 2022

Wrong Date Calculation - SharePoint

  My Past - works fine   My Today shows = Yesterday   My Tomorrow show = Today   My 2+ Days.... shows = One day ahead!   Please see the screenshot:       Code -    "txtContent": ...
  • kalpeshvaghela's avatar
    Aug 08, 2022

    SP1 

     

    May be because of time zone issue.

    You can also try to create Calculated column instead of SharePoint JSON column formatting.

     

    You can use below formula for SharePoint Calculated column, in my case it gives correct result now.

     

    =CONCATENATE("(",IF(TEXT(DueDate,"mm/dd/yyyy")-TEXT(NOW(),"mm/dd/yyyy")=0,"Today",IF(TEXT(DueDate,"mm/dd/yyyy")-TEXT(NOW(),"mm/dd/yyyy")=-1,"Yesterday",IF(TEXT(DueDate,"mm/dd/yyyy")-TEXT(NOW(),"mm/dd/yyyy")=1,"Tomorrow",IF(TEXT(DueDate,"mm/dd/yyyy")-TEXT(NOW(),"mm/dd/yyyy")>1,CONCATENATE(TEXT(DueDate,"mm/dd/yyyy")-TEXT(NOW(),"mm/dd/yyyy")," days"),IF(TEXT(DueDate,"mm/dd/yyyy")-TEXT(NOW(),"mm/dd/yyyy")<1,CONCATENATE(TEXT(NOW(),"mm/dd/yyyy")-TEXT(DueDate,"mm/dd/yyyy")," days ago"),""))))),")")

     

     

    Below is the output which I am getting now.

     

     

    Hope it will helpful to you. Please mark and like this answer as best response if it works for you so that it can help to other people.

     

     

Resources