given a date how to get the sunday of the week
# ask-stanley-ai
v
given a date how to get the sunday of the week
c
AI generated answer (using internal Slack threads):
To get the Sunday of the next week given a date, you can use the
NEXT_DAY
function in combination with the
DATEADD
function. The
NEXT_DAY
function returns the first weekday that is greater than a date. The weekday is specified as a string (e.g., 'SUNDAY'). The
DATEADD
function adds a specified time interval to a date. Here is a sample formula that you can use:
Copy code
sql
CASE
   WHEN {duedate} <= NEXT_DAY({today},'SUNDAY')
   THEN DATEADD('day', 7, NEXT_DAY({today},'SUNDAY'))
   ELSE {duedate}
END
In this formula, if the
duedate
is less than or equal to the next Sunday from today, it adds 7 days to the next Sunday from today, effectively giving you the Sunday of the next week. If the
duedate
is not less than or equal to the next Sunday from today, it simply returns the
duedate
. ****** 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.823921919
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822015166
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.794435084
Please provide your feedback on this answer.