Why is this an invalid expression in a saved searc...
# ask-stanley-ai
a
Why is this an invalid expression in a saved search formula? TO_CHAR('2025', 'YYYY')
c
AI generated answer (using internal Slack threads):
The expression
TO_CHAR('2025', 'YYYY')
is invalid in a saved search formula because the
TO_CHAR
function is used to convert dates or numbers to strings, not strings to strings. In this case, '2025' is already a string, so there's no need to convert it. If you want to convert a date or number to a string, you should use a field that contains a date or number as the first argument. For example, if you have a date field called
createdfrom.transhippeddate
, you could use
TO_CHAR({createdfrom.transhippeddate}, 'YYYY-MM-DD')
to convert the date to a string in the format 'YYYY-MM-DD'. Remember,
TO_CHAR
is a search/SQL function, not a freemarker function. If you need to format dates in a freemarker template, then you need to use a freemarker function. Also, when using dates in a formula, you should use the
TO_DATE
function to ensure that the dates are interpreted correctly. For example,
TO_DATE('7/15/2021', 'MM/DD/YYYY')
. ****** 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.825988829
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824584961
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.82208252
Please provide your feedback on this answer.