Need a filter for today from a date time field

Hey
I have a few fields with date time values in them.
Unable to create a filter using the existing data to today.
Also tried creating a calculated field of only the date, but doesnt work either.
Approciate any assiatance !
TIA

0 3 925
3 REPLIES 3

Hey there @Yunus88!

For this use case, it sounds like we want to filter for today's values only from your date time field. There are a couple of ways to do this in Looker:

  • Create a "is in the last 1 days" filter

Screenshot 2024-11-01 at 9.02.43 AM.png

Although it may seem like this would filter for the last 24 hours, the general logic of this filter equates to "is greater than today's date, and is less than tomorrow's date" in the generated SQL. For example, this is the generated SQL for that query logic in MySQL:

Screenshot 2024-11-01 at 9.04.51 AM.png

  • Use a matches (advanced) type filter

If you want your end users to see a filter value like "today" in their filters since that may be more intuitive than the above option, try switching to a matches (advanced) filter on your date time field instead:

Screenshot 2024-11-01 at 9.07.16 AM.png

The cool part about this approach is that the matches (advanced) filter has access to all of Looker's various filter expressions (including all of these relative timeframe options like "today", "this week", etc.).

Either of those options should give you a filter on a `date_time` field that filters for only today's data!

Thanks David !
I was actually trying to filter data of a chart in the Set-up Menu , by adding a filter for Filter for this chart.

Images attached for your ref. to see the options avaliable, I dont see the option you've given.

Screenshot 2024-11-02 at 7.38.14 PM.pngScreenshot 2024-11-02 at 7.37.55 PM.png

@Yunus88 ahh gotcha, so this is in Looker Studio, not Looker. That at least answers why our user interfaces looked different! 🙂

So for this, can you try changing the "Select a condition" dropdown to "Is This" and then choose "Day" from the subsequent menu? I believe that should work here!