Reputation: 4494
I need to create a date in a mysql query - but just the year part, I have tried:
SELECT STR_TO_DATE('01,5,'year(now()),'%d,%m,%Y');
But that does not work.
All I need to do is change the year part - any ideas how to do this?
Upvotes: 0
Views: 312
Reputation: 2049
The STR_TO_DATE
function does not accept two strings as its first argument, you need to concatenate the day and month with your year expression, using CONCAT
.
SELECT STR_TO_DATE(CONCAT('01,5,',YEAR(NOW())),'%d,%m,%Y');
Upvotes: 2
Reputation: 219934
If you know the two other parts just use CONCAT()
SELECT CONCAT(YEAR(CURDATE()), '-05-01')
Upvotes: 0