web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Conditional Formatting...
Power Apps
Unanswered

Conditional Formatting date field to display date in red if greater than today on a label in a gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Could someone help me with the code to get a label in a gallery to show the date value as red if the labels date value (SharePoint date and time column) is greater than today

 

The following code doesnt work?

 

If(Value(ThisItem.'DUEDATE') <Today(), Red, Black)

 

Any help would be appreciated

Categories:
I have the same question (0)
  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    If you want to set the color to red if the due date is greater than today, then the color property of the date label should be:

    If(Value(ThisItem.'DUEDATE') >Today(), Red, Black)

    However, I assume you wanted to say if the due date is lesser than today. If this isnt working, you can try 2 things:

    1. Use the Now() function instead. The Now function returns the current date and time as a date/time value.

    The Today function returns the current date as a date/time value. The time portion is midnight. Today has the same value throughout a day, from midnight today to midnight tomorrow.

    Since your due date is date/time, this might help for a better comparison.

    2. If you are only concerned about the date portion, then you can convert your due date to a date only value and then compare it with today. So something like this:

    Date(Year(ThisItem.DueDate), Month(ThisItem.DueDate), Day(ThisItem.DueDate))

    Also, if your ThisItem.DueDate is text, you shouldnt be using Value function. You probably need to use DateTimeValue function to convert that text or string into a date time value.

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

    Hardit(Haman)

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Could you please share a bit more about your scenario?

    Do you want to compare the 'DUEDATE' field value with Today?

     

    Based on the formula you provided, I think there is somthing wrong with it. I have made a test on my side, please consider take a try with the following workaround:

    Set the Color property of the Label in your Gallery to following:

    If(ThisItem.'DUEDATE' > Today(), Red, Black)

    Note: I assume that the 'DUEDATE' field a Date type column in your data source.

    Or

    If(Value(ThisItem.'DUEDATE') > Value(Today()), Red, Black)

    or

    If(
     Value(Text(ThisItem.'DUEDATE', "yyyymmdd")) > Value(Text(Today(), "yyyymmdd")), 
     Red, 
     Black
    )

     

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-xida-msft wrote:

    Hi @Anonymous ,

    Could you please share a bit more about your scenario?

    Do you want to compare the 'DUEDATE' field value with Today?

     

    Based on the formula you provided, I think there is somthing wrong with it. I have made a test on my side, please consider take a try with the following workaround:

    Set the Color property of the Label in your Gallery to following:

     

    If(ThisItem.'DUEDATE' > Today(), Red, Black)

     

    Note: I assume that the 'DUEDATE' field a Date type column in your data source.

    Or

     

    If(Value(ThisItem.'DUEDATE') > Value(Today()), Red, Black)

     

    or

     

    If(
     Value(Text(ThisItem.'DUEDATE', "yyyymmdd")) > Value(Text(Today(), "yyyymmdd")), 
     Red, 
     Black
    )

     

     

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,


    This is the code that works for me

     

    If(Value(ThisItem.'DUEDATE') > Value(Today()), Red, Black)

     

    Would you be able to tell me the code that would make it red if greater than today and orange if the date is between 30 days and today? and black if greater than 30 days? 

     

    Im trying several pieces of code however i cant get it to work? does it matter that my date format is shortdatetime? as if i use "dd-mm-yyyy" the Au timezone code appears and i cant use that?  

  • KatLane Profile Picture
    73 on at

    @Anonymous Did you get a solution to the orange date between 30 days and today?  I'm looking to do the same thing.  Also, I can't seem to make my date colour go back to black if the date is Today or greater.  I've tried both code options above and both work to change to red, but can't get to black if it's greater.

  • elvinvaz Profile Picture
    9 on at

    How could I create a condition where the FIll of an item turns colors after 30 minutes based on the Time of Item was created and the current time? 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard