Number of days in a month
to_char() and stuff when doing arithmetics with dates.Strings are strings and dates are dates. Please respect the data types and use this instead:
Indeed, this is correct. It computes the difference between the value of the last day of the month and the value of the first (which is obviously always 1 and therefore we need to add this 1 again).
You must not forget to use the
trunc() function if your date columns contains time, because
last_day() preserves the time component.