Now we have used the last day of the month, and tried it with the date in SQL. An error occurred, so we must use a valid date,
The followingCodeIs used in the test
Procedure tform1.button1click (Sender: tobject );
VaR
Fisc: string;
SS: string;
M1, M2: tdatetime;
Nextmonth: tdatetime;
Curmonth: tdatetime;
Maxday: string;
M, Y: DWORD;
MS, YS: string;
Begin
M1: = strtodate ('2017-09-29 ');
M2: = strtodate ('2017-10-28 ');
M: = dateutils. monthof (m2 );
Y: = dateutils. yearof (m2 );
MS: = inttostr (m );
YS: = inttostr (y );
Nextmonth: = strtodate (YS + '-' + inttostr (m + 1) + '-01'); // obtain the number 1 of the next month
Curmonth: = strtodate (YS + '-' + inttostr (m) + '-01'); // obtain the number 1 of the current month
showmessage (floattostr (nextmonth-curmonth); // 31
showmessage (datetostr (dateutils. endofthemonth (curmonth); // 2007-10-31
showmessage (datetostr (dateutils. endoftheday (curmonth); // 2007-10-01
showmessage (datetostr (dateutils. endoftheyear (curmonth); // 2007-12-31
showmessage (datetostr (dateutils. endofamonth (Y, M); // 2007-10-31
end;