DATETIME values in SQL-type languages can be tricky sometimes! There are 12 months, anywhere from 28 to 31 days in each month, and either 365 or 366 days in each year (for leap years)! This makes it hard to standardize months and date periods in your queries.
We often need to organize data by month, but with different month lengths, this can be hard! A standard practice is to assign all rows with a date in the month to a column labeled with the last day of that month. Or, maybe you need to figure out the date one or two months from now, but don’t know how long the month will be.
How do you find the last day of the month for a given date? The answer is different, depending on which type of SQL database you use. This tutorial will show you your options for T-SQL, MySQL, PostgreSQL, and Teradata…