惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Exploit Database - CXSecurity.com
F
Fortinet All Blogs
U
Unit 42
F
Full Disclosure
雷峰网
雷峰网
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
罗磊的独立博客
D
DataBreaches.Net
C
Check Point Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
O
OpenAI News
C
CXSECURITY Database RSS Feed - CXSecurity.com
aimingoo的专栏
aimingoo的专栏
S
Security @ Cisco Blogs
大猫的无限游戏
大猫的无限游戏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Hacker News
The Hacker News
Webroot Blog
Webroot Blog
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
N
News | PayPal Newsroom
P
Proofpoint News Feed
B
Blog RSS Feed
MongoDB | Blog
MongoDB | Blog
C
Cybersecurity and Infrastructure Security Agency CISA
N
News and Events Feed by Topic
Google Online Security Blog
Google Online Security Blog
H
Help Net Security
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
M
MIT News - Artificial intelligence
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
IT之家
IT之家
MyScale Blog
MyScale Blog
腾讯CDC

博客园 - lui

阿里云SSL证书到期(续期)图文教程 IIS7配置HTTPS+默认访问https路径 SQL将多行数据合并成一行【转】 arcgis 服务网页打开需要输入用户名和密码问题解决 Arcgis for js加载百度地图 android-studio-ide 安装到运行第一个helloword,坑记录 Hyper-V虚拟机联网设置 arcgis--arcmap导出点的X,Y坐标 mysql查看锁表与解锁 arcgis10.2怎么把地理坐标系转化为投影坐标系(平面,米制坐标) arcmap 10.2 从 WGS_1984 转 Beijing_1954 mysql 转换13位数字毫秒时间 【win10系统问题】远程桌面登录一次后,第二次登录看不到用户名和密码输入框 如何更改Arcmap里经纬度小数点后面的位数? 腾讯视频qlv格式转换MP4普通视频方法 kettle_Spoon 修改共享DB连接带汉字引发的错误 AutoCAD2015激活码和密钥 SQL语句 不足位数补0 c# winform 服务器提交了协议冲突. Section=ResponseStatusLine java.net.ProtocolException: Server redirected too many times
SQL获取本周,上周,本月,上月第一天和最后一天[注:本周从周一到周天]
lui · 2018-06-18 · via 博客园 - lui
DECLARE @ThisWeekStartTime NVARCHAR(100),@ThisWeekEndTime NVARCHAR(100),--本周
            @LastWeekStartTime NVARCHAR(100),@LastWeekEndTime NVARCHAR(100),--上周
            @ThisMonthStartTime NVARCHAR(100),@ThisMonthEndTime  NVARCHAR(100),--本月
            @LastMonthSartTime NVARCHAR(100),@LastMonthEndTime NVARCHAR(100),--上月
            @LastestHalfYearStartTime NVARCHAR(100),@LastestHalfYearEndTime NVARCHAR(100),--近半年
            @LastestOneYearStartTime NVARCHAR(100),@LastestOneYearEndTime NVARCHAR(100)--近一年
            
    SELECT @ThisWeekStartTime= CONVERT(nvarchar(10), DATEADD(wk, DATEDIFF(wk,0,DATEADD(dd, -1, getdate()) ), 0),121)--本周开始时间
    SELECT @ThisWeekEndTime= CONVERT(nvarchar(10), DATEADD(wk, DATEDIFF(wk,0,DATEADD(dd, -1, getdate()) ), 6),121)--本周结束时间
    
    SELECT @LastWeekStartTime=  CONVERT(nvarchar(10),DATEADD(wk, DATEDIFF(wk,0,DATEADD(dd, -7, getdate()) ), 0),121)--上周开始时间
    SELECT @LastWeekEndTime= CONVERT(nvarchar(10), DATEADD(wk, DATEDIFF(wk,0,DATEADD(dd, -7, getdate()) ), 6),121)--上周结束时间
     
    SELECT @ThisMonthStartTime=CONVERT(nvarchar(10),dateadd(dd,-day(getdate())+1,getdate()),121)--本月开始时间
    SELECT @ThisMonthEndTime=CONVERT(nvarchar(10),dateadd(dd,-day(getdate()),dateadd(m,1,getdate())),121)--本月结束时间
    
    SELECT @LastMonthSartTime=CONVERT(nvarchar(10),dateadd(dd,-day(dateadd(month,-1,getdate()))+1,dateadd(month,-1,getdate())),121)--上月开始时间
    SELECT @LastMonthEndTime= CONVERT(nvarchar(10), dateadd(dd,-day(getdate()),getdate()),121) --上月结束时间
 
    SELECT @LastestHalfYearStartTime= CONVERT(nvarchar(10),  dateadd(dd,-day(dateadd(month,-6,getdate()))+1,dateadd(month,-6,getdate())) ,121)--近半年开始时间
    SELECT @LastestHalfYearEndTime=CONVERT(nvarchar(10), dateadd(dd,-day(getdate()),getdate()),121)--近半年结束时间
    
    SELECT @LastestOneYearStartTime= CONVERT(nvarchar(10), dateadd(dd,-day(dateadd(month,-12,getdate()))+1,dateadd(month,-12,getdate())) ,121)--近一年开始时间
    SELECT @LastestOneYearEndTime=CONVERT(nvarchar(10), dateadd(dd,-day(getdate()),getdate()),121)--近一年结束时间

===================================================================================================

当前时间 select getdate()
当前时间周的起始日期(以周一为例)select DATEADD(week,DATEDIFF(week,0,getdate()),0)
上周起始:select dateadd(week,-1,DATEADD(week,DATEDIFF(week,0,getdate()),0))
上上周起始:select dateadd(week,-2,DATEADD(week,DATEDIFF(week,0,getdate()),0))
上上上周起始:select dateadd(week,-3,DATEADD(week,DATEDIFF(week,0,getdate()),0))