Least of 2 Dates

Is it possible to pick the least of 2 dates. SQL function would be: least(a.date,b.date)::date

I am aware there is a TS formula for least - but looks like it only takes numeric values. 

5replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • ThoughtSpot_Administration_Guide_4.2 lists greatest and least under mixed functions (can be used with text and numeric data types) on page 299. However looking through available formulas in UI, greatest/least only appears under numeric. 

    Like
  • Hi Steph Fisher - would something like the below work?

     

    if(diff_days( date1 , date2 )<0) then date1 else date2

    Like
  • Micah Terry - Doesn't work. I get the following error: Formula not supported where we mix quantities across a many-to-many join.

    I'm guessing the error is related to the chasm trap I have present on the worksheet.

    Like
  • Steph Fisher , yes the issue here is related to the chasm trap. Because of the chasm trap, we could have multiple values of date1 for each date2 and multiple values of date2 for each date1 and hence cannot determine this. You can check out the if formula over 2 fields from the same table.

    Like
  • Thanks Siva . Disappointing news, but figured as much.

    Like
Like Follow
  • Status Answered
  • 2 yrs agoLast active
  • 5Replies
  • 474Views
  • 3 Following