![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1
--
当前月的第一天
2 SELECT DATEADD ( month , DATEDIFF ( month , 0 , getdate ()), 0 );
3
4 -- 当前月的最后一天
5 SELECT DATEADD ( month , DATEDIFF ( month , 0 , getdate ()) + 1 , 0 ) - 1 ;
6
7 -- 当前季度的第一天
8 SELECT DATEADD (quarter, DATEDIFF (quarter, 0 , getdate ()), 0 );
9
10 -- 当前季度的最后一天
11 SELECT DATEADD (quarter, datediff (quarter, - 1 , getdate ()) , - 1 );
12
13 -- 当前年的第一天
14 SELECT DATEADD ( year , DATEDIFF ( year , 0 , getdate ()), 0 );
15
16 -- 当前年的最后一天
17 SELECT DATEADD ( year , DATEDIFF ( year , - 1 , getdate ()), - 1 );
18
2 SELECT DATEADD ( month , DATEDIFF ( month , 0 , getdate ()), 0 );
3
4 -- 当前月的最后一天
5 SELECT DATEADD ( month , DATEDIFF ( month , 0 , getdate ()) + 1 , 0 ) - 1 ;
6
7 -- 当前季度的第一天
8 SELECT DATEADD (quarter, DATEDIFF (quarter, 0 , getdate ()), 0 );
9
10 -- 当前季度的最后一天
11 SELECT DATEADD (quarter, datediff (quarter, - 1 , getdate ()) , - 1 );
12
13 -- 当前年的第一天
14 SELECT DATEADD ( year , DATEDIFF ( year , 0 , getdate ()), 0 );
15
16 -- 当前年的最后一天
17 SELECT DATEADD ( year , DATEDIFF ( year , - 1 , getdate ()), - 1 );
18