Concatenate the last day of the month to a date.

Database
Enthusiast

Concatenate the last day of the month to a date.

Good Afternoon,

My question is this what I want to do is to a date depending on the month to add the last day of the month.

For example I get:

201001 and it looks like this 20100131

Thanks in advance.

1 REPLY
Senior Supporter

Re: Concatenate the last day of the month to a date.

It will depend on which datatype your 201001 is

Try

select '201001' as dt_char, 201002 dt_int, add_months((dt_char!!'01' \

(date,format'YYYYMMDD')),1)-1, add_months((((dt_int - 190000)*100 +1) \

(date)),1)-1;

in both cases - create the first of the month as a dat ->  Add one month -> substract 1 day -> last day