Can you write a case formula for a summary type sa...
# ask-stanley-ai
m
Can you write a case formula for a summary type saved search that finds the oldest date and the newest date and then concat the two dates
c
AI generated answer (using internal Slack threads):
Based on the conversations provided, it seems you are looking for a formula that can be used in a saved search to find the oldest and newest date from two date fields and then concatenate these two dates. You can use the
CASE
statement in your formula to compare the two date fields and return the oldest and newest date. Here is a sample formula:
Copy code
sql
CASE 
    WHEN {date1} > {date2} THEN TO_CHAR({date1}, 'YYYY-MM-DD') || ' - ' || TO_CHAR({date2}, 'YYYY-MM-DD')
    WHEN {date1} < {date2} THEN TO_CHAR({date2}, 'YYYY-MM-DD') || ' - ' || TO_CHAR({date1}, 'YYYY-MM-DD')
    ELSE 'Dates are equal or not valid'
END
This formula will compare
date1
and
date2
. If
date1
is greater than
date2
, it will return a string with
date1
and
date2
concatenated, with
date1
being the newest date and
date2
being the oldest date. If
date1
is less than
date2
, it will return a string with
date2
and
date1
concatenated, with
date2
being the newest date and
date1
being the oldest date. If the dates are equal or not valid, it will return a message saying 'Dates are equal or not valid'. Please replace
date1
and
date2
with your actual field IDs. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849646091
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826448381
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823387921
Please provide your feedback on this answer.