Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql “to_char”不是可识别的内置函数名_Sql_Sql Server_Date_Type Conversion_To Char - Fatal编程技术网

Sql “to_char”不是可识别的内置函数名

Sql “to_char”不是可识别的内置函数名,sql,sql-server,date,type-conversion,to-char,Sql,Sql Server,Date,Type Conversion,To Char,错误: (to_char(sysdate,'YYYY')+least(sign((sysdate-to_date('01-Aug-'|| to_char(sysdate,'YYYY'),'DD-Mon-RRRR'))),0)) "AcYear" 我尝试更改为_char和_date进行转换,但出现错误 我预计2016年将是一个新的赛季 有人可以帮忙吗?在SQL Server中,如果您想要8月1日,请使用datefromparts: 这适用于SQL Server 2012+。早期版本需要稍

错误:

    (to_char(sysdate,'YYYY')+least(sign((sysdate-to_date('01-Aug-'||
to_char(sysdate,'YYYY'),'DD-Mon-RRRR'))),0)) "AcYear"
我尝试更改为_char和_date进行转换,但出现错误

我预计2016年将是一个新的赛季


有人可以帮忙吗?

在SQL Server中,如果您想要8月1日,请使用datefromparts:

这适用于SQL Server 2012+。早期版本需要稍微多做一些工作:

select datefromparts(year(getdate()), 8, 1)

您确定正在使用sql server吗?to_char不是sql server中的函数。Oracle不是sql server:函数各不相同。您不理解的消息是什么?为什么在SQL Server中使用Oracle/Postgres/Teradata函数?至少,你应该编辑你的问题,并提供样本数据和期望的结果。
select datefromparts(year(getdate()), 8, 1)
select cast(datename(year, getdate()) + '0801' as date)