START TIMESTAMPS and END TIMESTAMPS based on a week or month number from a NOW timestamp

Michael Udinski Chris Coleman

I know I have filters in XANO to get week number and month number of the year based on time stamp - but is there a way to return START TIMESTAMPS and END TIMESTAMPS for the range(s) after I get those values???

In other words: for a “this week” option - I could inout a timestamp for NOW - and get the timestamps for the START of “this calendar week” and the END of “this calendar week” so that I can search for something in another table that is between those timestamps?

I see there is an SQL function ??

-- Replace '2024' with your desired year and 'week_number' with the week number (1-53)

SELECT

DATE_TRUNC('week', DATE '2024-01-01' + INTERVAL '1 week' * (week_number - 1)) AS start_of_week,

DATEADD('day', 6, DATE_TRUNC('week', DATE '2024-01-01' + INTERVAL '1 week' * (week_number - 1))) AS end_of_week;

1
5 replies