It will depend on the database you’re using!
As you can see below, there can be quite some variations in syntax between Vertica, SQL Server, MySQL, PostgreSQL
So, what’s common in all these examples? In all cases, you will need:
- a function that gets the current date
- a function that extracts the year from the current date
- a function that concatenates strings
- a function that converts a string to a date
Need help with those?
Check out my other blog posts:
- How can I get the current time with SQL?
- How do I extract part of a date with SQL?
- How do I concatenate strings with SQL?
- How do I convert string to a date with SQL?