Forum Discussion

chudson002's avatar
chudson002
Brass Contributor
Jul 18, 2020

CONDITIONAL FORMATTING OF DATE COLUMN

Hello Community,

 

Have a column with a date.  When I apply conditional formatting, the time pops into the column
12:00:00 AM.  How can this be removed?

 

Thanks.

2 Replies

  • chudson002, You can use toLocaleDateString() function which returns a language sensitive representation of just the date portion of a date-time field.

    For Example:

     

     

    "txtContent":"=toLocaleDateString(@now)"

     

     

    This will return a result like "7/19/2020". However, results may vary based on user's locale.

    Use column formatting to customize SharePoint - Operators 


    Please click Mark as Best Response if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it Like.

  • RobElliott's avatar
    RobElliott
    Silver Contributor

    Hi chudson002 using the built-in formatting I don't know of a way to remove the time. But by going to advanced mode you can add your own JSON for conditional formatting on the date column. For example:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "padding-left": "14px",
        "background-color": "=if(@currentField <= @now, '#c00000','teal')",
        "color": "white"
      }
    }

     

    will give the following result:

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User

Resources