cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shaneOZ
Level 8

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

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

3 REPLIES 3
Super User
Super User

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

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)

Community Support Team
Community Support Team

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

Hi @shaneOZ ,

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 Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
shaneOZ
Level 8

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


@v-xida-msft wrote:

Hi @shaneOZ ,

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?  

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,396)