Home > Software engineering >  how to combine parameters of a date function to get the last day of a particular year in an postgres
how to combine parameters of a date function to get the last day of a particular year in an postgres

Time:08-24

I need a last day of a particular year as a date in an sql query: date(table1.year "-12-31") throws: ERROR: column "-12-31" does not exist how is it possible to concatenate it an get the date?

CodePudding user response:

I identified your DB as MySql. In this case do

    select date(concat(table1.year,'-12-31'))

in the fiddle, this select date(concat('1999','-12-31')) fetches this 1999-12-31

BTW in postgres this is also valid

  • Related