Knowledge Drop

How do I compare dates in table calcs?

  • 5 April 2021
  • 0 replies

Userlevel 5
  • Looker Staff
  • 172 replies

Last tested: June 2020

There are two methods for date comparison in table calcs.

  1. Use diff_days or any of the other diff_ functions (docs).
    For example, to say "${date_a} > $[date_b}", just do diff_days(${date_b},${date_a}) > 0.

  2. The extract_ familiy of functions can be useful since they let you extract a numeric value (year, month, day, etc) from a date or timestamp. Docs on that.
    If you need something simple like "date is after January 1, 2017", then just do extract_years(${date}) > 2017.

This content is subject to limited support.                

0 replies

Be the first to reply!