user2500196
user2500196

Reputation: 89

Trying to get Month-Year from Date in SSRS while using Query

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

Answers (1)

Amit
Amit

Reputation: 15387

Try this

SELECT Month(adempiere.c_invoice.dateinvoiced)+"-"+ DATEPART(year,adempiere.c_invoice.dateinvoiced)  
   FROM adempiere.c_invoice

Upvotes: 1

Related Questions