SQL服务器数据部分的年和月
16lz
2021-01-22
I have a call in SQL Server 2012 that I need to have working on Server 2005 and 2008.
我有一个SQL Server 2012的电话,我需要在Server 2005和2008上工作。
FORMAT(Date, 'yyyyMM') = 201501
is what I am currently using and need to use DATEPART older versions of SQL Server but cannot see a way of doing it easily.
格式(日期,' yyymm ') = 201501是我目前正在使用的,并且需要使用DATEPART较老版本的SQL Server,但是不能很容易地看到这样做的方法。
Any help would be very much appreciated.
如有任何帮助,我们将不胜感激。
4 个解决方案
#1
3
Earlier versions of SQL Server don't have the FORMAT
, so you'd need to so something like
SQL Server的早期版本没有这种格式,因此需要类似的格式
YEAR(Date) = 2015 AND MONTH(Date) = 1
or something like that to check the two conditions
或者类似的东西来检验这两个条件
更多相关文章
- Mysql5.7.10版本安装后空密码登录,退出后提示密码错误连接不上解
- 如何通过使用where子句与字符串格式(varchar(103),...,10)将103格式化
- 如何用sql语言只获得数据库当前日期,且格式为"yyyy-mm-dd"?
- MySQL5.7.11版本,64位绿色版安装
- 3、Oracle PL/SQL中Date格式及格式转换
- 利用Shell脚本将MySQL表中的数据转化为json格式
- oracle --sql--转换表字段日期格式(年月日时分秒转换年月日)
- SQL Server 2012失败:导入平面文件时,日期为yyyyy.m.dd格式
- SQLite格式编号始终为2位小数