CalcDate

Hi,

Can some one please tell me how to figure out the month end date if we have a date in this format: 200401

So, i dont have the complete date but just the month and the year. I was told to use the CalcDate function. Can someone please help me? Thank you.

The way to calculate the last day of the month is to use ‘<+CM>’ as the DateExpression parameter of the CALCDATE. You could pull the year and the month out of the 6 digit string into two separate integer variables, and build a date with the DMY2DATE function, and then use the CALCDATE function to calculate the last day of the month.

Something like this:

MySixDigitString := ‘200504’;
EVALUATE(YearNo,COPYSTR(MySixDigitString,1,4));
EVALUATE(MonthNo,COPYSTR(MySixDigitString,5,2));
MyDate := DMY2DATE(1,MonthNo,YearNo);
MyDate := CALCDATE(’<+CM>’,MyDate);
MESSAGE(FORMAT(MyDate));

YearNo and MonthNo are Integers, MySixDigitString is a text variable, and MyDate is a date variable.