Reputation: 89
I've been trying to get Month-Year from the Date.
My code is
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, adempiere.c_invoice.dateinvoiced, 0))
FROM adempiere.c_invoice
The error that i get when i Edit as Text is
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
When im in the query designer in data server tools and i "Run SQL"
The program automatically adds (") to the Month becoming "Month" and adds "AS Expr1" behind. It becomes like this
SELECT DATEADD("MONTH", DATEDIFF("MONTH", 0, adempiere.c_invoice.dateinvoiced, 0)) AS Expr1
FROM adempiere.c_invoice
And the error is
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
thanks so much for reading and hope someone can help me!
Upvotes: 0
Views: 481
Reputation: 15387
Try this
SELECT Month(adempiere.c_invoice.dateinvoiced)+"-"+ DATEPART(year,adempiere.c_invoice.dateinvoiced)
FROM adempiere.c_invoice
Upvotes: 1