Last active
March 12, 2018 16:06
-
-
Save infinex/0b000604c8a1e762572c0cba9a6c77b1 to your computer and use it in GitHub Desktop.
big query date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #standard sql | |
| SELECT "Current Month" as type,cast(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), MONTH) as date) | |
| UNION ALL | |
| SELECT "Week ending",DATE_ADD(cast(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), WEEK) as date),interval 7 DAY) | |
| UNION ALL | |
| SELECT "Current Month",DATE_TRUNC(CURRENT_DATE,MONTH) | |
| UNION ALL | |
| SELECT "First day of last Month",DATE_TRUNC(DATE_SUB(CURRENT_DATE,INTERVAL 1 MONTH),MONTH) | |
| UNION ALL | |
| SELECT "Last day of the currrent month",DATE_SUB(DATE_TRUNC(DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH), MONTH), INTERVAL 1 DAY) | |
| UNION ALL | |
| SELECT "Last day of the previous month",DATE_SUB(DATE_TRUNC(CURRENT_DATE(), MONTH), INTERVAL 1 DAY) | |
| UNION ALL | |
| SELECT "Last day of the two month",DATE_SUB(DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH), MONTH), INTERVAL 1 DAY) | |
Author
infinex
commented
Mar 12, 2018

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment