Skip to content

Instantly share code, notes, and snippets.

@cgi-ace
Created June 15, 2021 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgi-ace/fb260d80b94c8b41a0562a0bbf2c397a to your computer and use it in GitHub Desktop.
Save cgi-ace/fb260d80b94c8b41a0562a0bbf2c397a to your computer and use it in GitHub Desktop.
---- First day and last day of a month for dynamically using it in _TABLE_SUFFIX
with tablemonth as (
SELECT CAST(FORMAT_DATE("%Y%m%d",DATE_TRUNC(CURRENT_DATE(), MONTH)) as string) as st_date_month,
CAST(FORMAT_DATE("%Y%m%d",DATE_SUB(DATE_TRUNC(DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH), MONTH), INTERVAL 1 DAY)) as string) as end_date_month
)
select * from tablemonth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment