September 18, 2024

# Power Apps: IsToday Function

IsToday function is what I can a “nice to have” function, and I’m happy it exists. Although you could do the math yourself, having a function that tells you if your date/time belongs to the current day is fantastic. There are a lot of applications for this, but I think Microsoft included this one since Power Apps deal with a lot of customer-facing information, most of them filtered by the current day. If we needed to implement the calculations ourselves each time we wanted to filter something by the present day, it would be a mess of code.

So let’s look a bit at how the IsToday function works.

## Usage

It follows a simple pattern.

1. Date and time to compare

``````IsToday(Now())

will return

true
``````

It looks obvious but remembers that the Now function returns date and time. So calculating if the time fit’s on your definition of “today” depending on timezones and daylight savings is quite impressive.

Now let’s create the date with the “Date” function and see what we get:

``````IsToday(Date(2021,9,30))

will return

true
``````

Now let’s try with strings:

``````IsToday('2021-09-30')

will return an error
``````

Although the date is valid, we need to convert it first before using it. To do that, we’re using the DateTimeValue function.

``````IsToday(DateTimeValue("2021-09-30"))

will return (today is the 30th of September 2021)

true
``````

## Limitations

It’s a limitation, in my opinion, but a reasonable restriction that the function only accepts “date/time” objects. Allowing other objects, like timestamps and strings, would make things a lot more complex. This way, the function can limit its domain to “checking if the date is today” instead of “convert if needed, check if it’s a date, and then check if the date is today”. It’s complex enough the do the checking correctly.

## Recommendations:

### Don’t do the math

The whole point of the IsToday function is so that you don’t need to do the math. So, for example, you don’t need to parse the date and check if the day, month, and year is the same as the current date, the time is under the same timezone, and if not, convert it, etc.

It does all of this for you, so please use it.

## Sources:

Now, Today, and IsToday functions in Power Apps

Back to the Power Apps Function Reference

Photo by Danielle MacInnes on Unsplash

#### Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →
Mastodon