How to find FIRST_DAY, LAST_DAY of current month, next month, previous month in Google Bigquery
Using #Standard SQL
First day of the current month:
SELECT DATE_TRUNC(CURRENT_DATE(), MONTH)
Last day of the current month (first day next month minus 1):
SELECT DATE_SUB(DATE_TRUNC(DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH), MONTH),
INTERVAL 1 DAY)
Last day of the previous month (first day current minus 1):
SELECT DATE_SUB(DATE_TRUNC(CURRENT_DATE(), MONTH), INTERVAL 1 DAY)
First day of the next month:
SELECT DATE_TRUNC(DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH), MONTH)
nVector
posted on 09 Apr 20Enjoy great content like this and a lot more !
Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds
Post Comment