开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 7753|回复: 0

date time format of t-sql

[复制链接]

0

精华

0

贡献

196

赞扬

帖子
67
软币
885
在线时间
74 小时
注册时间
2013-8-20
发表于 2013-8-26 08:34:20 | 显示全部楼层 |阅读模式
--- select convert(datetime,(convert(char(7),dateadd(month,-1,getdate()),111)+'/1')) ; last month first day
---select  dateadd(day,-1,convert(datetime,(convert(char(7),getdate(),111)+'/1')))  ; last month end day
---select convert(datetime,(convert(char(7),getdate(),111)+'/1'))   ;  this month first day
---select dateadd(day,-1,convert(datetime,(convert(char(7),dateadd(month,1,getdate()),111)+'/1'))) ; this month end day

---select convert(datetime,(convert(char(7),dateadd(month,1,getdate()),111)+'/1')) ; next month first day


ex: 2011/8/9
---SELECT CONVERT(VARCHAR(4),YEAR(GETDATE()))+'/'+CONVERT(VARCHAR(2),MONTH(GETDATE()))
+'/'+CONVERT(VARCHAR(2),DAY(GETDATE()))

回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-3-28 17:34

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表