cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

How to compare DateTime with Date?

Hello everyone,

So I have this code to get data for today. My current way of comparing is to convert both the dateTime and Date into the same text format.
LookUp(MyTable, Text(CreatedOnDateTime, "[$-en-US]dd/mm/yyyy") = Text(Today(), "[$-en-US]dd/mm/yyyy"))

Is there any easier/simpler expression to compare dateTime with date? Thanks in advance.

1 REPLY 1
Highlighted
Power Apps
Power Apps

Re: How to compare DateTime with Date?

Do you want your comparison to succeed only if the time part of the date/time expression is zero (00:00:00)? If so, then you can compare them directly:

LookUp(MyTable, CreatedOnDateTime = Today())

If you want to compare using only the date part of the DateTime expression, then you will need to use a conversion. Your solution is good, or you can also create a new Date value from the DateTime:

LookUp(
    MyTable,
    Date(Year(CreatedOnDateTime), Month(CreatedOnDateTime), Day(CreatedOnDateTime)) = Today())

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,439)