I have a table like so:
and I have this customID:
SELECT c.Id, CONCAT_WS('-', RIGHT(YEAR(DateCreated), 2), LPAD(c.Id,3,0)) as CustomID
Because it's 2021 - I now need it to reset back to 21-001
21-001
Current output:
Question:
What would be an appropriate method to alter this to desired output?
Desired
21-001 21-002
Instead of RIGHT(YEAR(DateCreated), 2) try RIGHT(YEAR(NOW()), 2)
RIGHT(YEAR(DateCreated), 2)
RIGHT(YEAR(NOW()), 2)
Every time a year pass the year will be reset and you save the DateCreated.
1.4m articles
1.4m replys
5 comments
57.0k users