elseif (p_period = 'LAST2CALENDARMONTHS') then
lMonthInt := 2;
lLastDay := date_trunc('month',current_date - interval '1 month') + INTERVAL '1 month - 1 day' + (interval '1 day - 1 second');
lFirstDay := date_trunc('month',current_date - (lMonthInt*INTERVAL '1 month'));
elseif (p_period = 'LAST3CALENDARMONTHS') then
lMonthInt := 3;
lLastDay := date_trunc('month',current_date - interval '1 month') + INTERVAL '1 month - 1 day'+ (interval '1 day - 1 second');
lFirstDay := date_trunc('month',current_date - (lMonthInt*INTERVAL '1 month'));
Using Postgresql, the above code converts a string into a FromDate and Todate, for example when I call LAST2CALENDARMONTHS
It will display fromdate: "2016-08-01 00:00:00" Todate: "2016-09-30 23:59:59"
I want to do the same for calling any month of the year, for example calling JANUARY the results should be:
fromdate: "2016-01-01 00:00:00" Todate: "2016-01-31 23:59:59"
Is something like this possible?