Hello Community,
I'm going to be straight with you and let you know that I have posted the following question to another SQL forum, but they aren't able to find a solution, so I am going ask you guys if you can help take a look at the following query and let me know why I keep on getting the following error:
1 Incorrect syntax near ','.
The query is a follows:
SELECT
*
FROM Data.Stock
WHERE Stock.DateBought BETWEEN CAST(YEAR(DATEADD(m, -1, GETDATE())) AS CHAR(4)), CAST(MONTH(DATEADD(m, -1, GETDATE())) AS VARCHAR(2)) AND EOMONTH(DATEADD(m, -1, GETDATE()))
The table is a follows:
CREATE TABLE [szen-ds-sql-rdp-tstdbase4].Data.Stock (
StockCode NVARCHAR(50) NULL
,ModelID SMALLINT NULL
,Cost MONEY NULL
,RepairsCost MONEY NULL
,PartsCost MONEY NULL
,TransportInCost MONEY NULL
,IsRHD BIT NULL
,Color NVARCHAR(50) NULL
,BuyerComments NVARCHAR(4000) NULL
,DateBought DATE NULL
,TimeBought TIME NULL
)
GO
and some data:
|StockCode|ModelID|Cost|RepairsCost|PartsCost|TransportInCost|IsRHD|Color|BuyerComments|DateBought|TimeBought|
|---|---|---|---|---|---|---|---|---|---|---|
|CF66838B-8A21-4084-9771-07A82CDBEBD8|86|7160.00|500.00|228.00|150.00|True|Dark Purple|(null)|29/10/2018|12:55:00|
|7461FB42-ECE2-4C8C-BDBB-EF26AF3069F9|87|7600.00|500.00|750.00|150.00|True|Green|(null)|29/10/2018|12:55:00|
|F287EE1D-48C6-4E75-9595-E0AE235FBEA8|86|7600.00|500.00|330.00|150.00|True|Green|(null)|01/11/2018|12:55:00|
I have also submitted the query to the following group, but without any luck
Any help will be grealy appreciated.
Cheers