Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Saber ultimo dia del mes (https://www.clubdelphi.com/foros/showthread.php?t=17793)

morfeo21 21-01-2005 18:13:39

Saber ultimo dia del mes
 
Que tal foro. Una pregutita , si me pueden ayudar .Deseo crear una funcion que al yo darle el mes y el año me devuelva el ultimo dia del mes indicado.
agradesco de antemano su ayuda . :p

Héctor Randolph 21-01-2005 18:30:21

Hola Morfeo!

Hay una función en Delphi que te devuelve los días que hay en cada mes y está implementada de la siguiente forma:

Código Delphi [-]
{ The MonthDays array can be used to quickly find the number of
  days in a month:  MonthDays[IsLeapYear(Y), M]      }
const
  MonthDays: array [Boolean] of TDayTable =
    ((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
     (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));

function DaysInAMonth(const AYear, AMonth: Word): Word;
begin
  Result := MonthDays[(AMonth = 2) and IsLeapYear(AYear), AMonth];
end;

La encuentras en la unidad Dateutils.pas

Un Saludo.

morfeo21 21-01-2005 19:06:18

Gracias Hector .El dato que me diste soluciono mi problema.


La franja horaria es GMT +2. Ahora son las 07:28:07.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi