0

我一直在尝试从日期中获取月份。

我的代码是

SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, adempiere.c_invoice.dateinvoiced, 0))    
FROM adempiere.c_invoice

我编辑为文本时得到的错误是

An error occured while executing the query.
ERROR [42703] ERROR: column "month" does not exist;
Error while executing the query

Additional information: ->
Error [42703] Error: column "month" does not exist; Error while executing the query (PSQLODBC.DLL

当我在数据服务器工具的查询设计器中并且我“运行 SQL”时

程序自动将Month加上(")变成了“Month”,在后面加上“AS Expr1”,就变成了这样

SELECT        DATEADD("MONTH", DATEDIFF("MONTH", 0, adempiere.c_invoice.dateinvoiced, 0)) AS Expr1
FROM            adempiere.c_invoice

错误是

SQL Execution Error

Executed SQL statement: SELECT DATEADD("MONTH", DATEDIFF("MONTH", 0, adempiere.c_invoice.dateinvoiced, 0)) AS Expr1
FROM adempiere.c_invoice
Error Source: PSQLODBC.DLL
Error Message: ERROR [42703] ERRPR: Column "MONTH" does not exist;
Error while executing the query

非常感谢您的阅读,希望有人可以帮助我!

4

1 回答 1

1

尝试这个

SELECT Month(adempiere.c_invoice.dateinvoiced)+"-"+ DATEPART(year,adempiere.c_invoice.dateinvoiced)  
   FROM adempiere.c_invoice
于 2013-07-02T13:24:31.957 回答