I need a query that retrieves a column which type is a date, but based on this column I also need to create another column in my query which takes year and month of this mentioned column, and as day use 1.
This is what I have:
SELECT
forecast_id,
name,
property_id,
property_name,
DATE(YEAR(last_day_of_month), MONTH(last_day_of_month), 1) AS forecast_month,
last_day_of_month,
FROM table_name;
I am getting an error, and I have no idea how I can get this column which takes the same year and month of one column that exist in my table, and just changes the day.
The error I am getting is:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' MONTH(last_day_of_month), 1) AS forecast_month, last_day_of_month, COUN' at line 6 0.00075 sec