First day of the next month
First day of next month: sql-server 2012+ DATEADD(d, 1, EOMONTH(current_timestamp)) sql-server 2008 and older: DATEADD(m, DATEDIFF(m, -1, current_timestamp), 0)
First day of next month: sql-server 2012+ DATEADD(d, 1, EOMONTH(current_timestamp)) sql-server 2008 and older: DATEADD(m, DATEDIFF(m, -1, current_timestamp), 0)
In PostgreSQL 9.4 and greater there is actually a make_date(year int, month int, day int) function that will create a date. https://www.postgresql.org/docs/current/functions-datetime.html
You can add Doctrine extension so you can use the MySql YEAR and MONTH statement by adding this configuration if you’re on Symfony: doctrine: orm: dql: string_functions: MONTH: DoctrineExtensions\Query\Mysql\Month YEAR: DoctrineExtensions\Query\Mysql\Year now you can use the MONTH and YEAR statements in your DQL or querybuilder. Note: The extension supports MySQL, Oracle, PostgreSQL and SQLite.
Simply subtract them: SELECT (‘2015-01-12’::date – ‘2015-01-01’::date) AS days; The result: days —— 11