To get the first date of month from a given date, you can run this command. From the example, you can replace the ‘2013-02-28’ date with your own date, or you can use variable when you want to use it inside a procedure.
The code below is code that get the first date of month from a given date. It works by subtracting the given date by the day value of the given date—obtained by using function EXTRACT(DAY FROM [given date]). This will return the last month’s last date. So, to get the first date of then month. You need to add 1 to the the day value of the given date.
The next code is to get the last date of the month. Once you got the first date, you can add 1 month so the date will be the first date of next month and then subtract it by 1 to get the date one day before next month first date which is equal to the last date of given date’s month.