All Forums Database
superjuanito88 17 posts Joined 05/12
09 Aug 2012
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.

ulrich 816 posts Joined 09/09
09 Aug 2012

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

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

You must sign in to leave a comment.