Last active
December 16, 2015 06:19
-
-
Save sheldonhull/5390417 to your computer and use it in GitHub Desktop.
common date manipulation to get EOM/BOM values
This file contains 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
declare @Date date = getdate() | |
select | |
previous_month_bom = dateadd(month, datediff(month, 0, @Date) - 1, 0) --previous_month_bom | |
,previous_month_eom = dateadd(day, -1, dateadd(month, datediff(month, 0, @Date), 0)) -- previous_month_eom | |
,bom = dateadd(month, datediff(month, 0, @Date), 0) -- bom | |
,eom = dateadd(month, datediff(month, 0, @Date) + 1, -1) -- eom | |
,next_bom = dateadd(month, datediff(month, 0, @Date) + 1, 0) -- next_bom | |
,next_eom = dateadd(day, -1, dateadd(month, datediff(month, 0, @Date) + 2, 0)) -- next_eom |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment