Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.09.29;
Скачать: CL | DM;

Вниз

Как прибавить к дате M месяцев?   Найти похожие ветки 

 
AL1000   (2003-09-18 09:17) [0]

Как прибавить к дате M месяцев?


 
Жёсткая логика ©   (2003-09-18 09:40) [1]

Функция IncMonth модуля SysUtils


 
app ©   (2003-09-18 09:50) [2]

Это конечно если устроит результат


 
Reindeer Moss Eater ©   (2003-09-18 09:53) [3]

31 января + 1 месяц это сколько должно получиться?


 
JohnJ ©   (2003-09-18 10:37) [4]

2 или 3 марта, в зависимости от года...


 
Reindeer Moss Eater ©   (2003-09-18 10:44) [5]

А по идее должно получаться 28 или 29 февраля в зависимости от года.


 
090909   (2003-09-18 10:48) [6]

procedure TAddKart.DBDateEdit1Change(Sender: TObject);
var
D, Dk, Dt, G, Gk, CH : integer;
DD : String;
begin
D:=0; Dk:=0; Dt:=0; G:=0; Gk:=0; CH:=0;
{d - текущий месяц
dk - конечный месяц
dt - разница
G - год
Gk - конечный}
D := RetDate(DBDateEdit1.Date,2);
G := RetDate(DBDateEdit1.Date,1);
CH := RetDate(DBDateEdit1.Date,3);
dk := d + 6;
if dk>12 then
begin
Dt := dk - 12;
gk := g + 1;
end
else
begin
gk := g;
Dt := dk;
end;

DD := Inttostr (DT)+"/"+Inttostr (CH)+"/"+Inttostr (GK);
DBDateEdit2.Date := VarToDateTime(dd);
end;


 
ZEE ©   (2003-09-18 10:48) [7]

из хелпа:
[code]function IncMonth(const Date: TDateTime; NumberOfMonths: Integer = 1): TDateTime;
...
[b]If the input day of month is greater than the last day of the resulting month, the day is set to the [u]last day[/u] of the resulting month.[/b] The time of day specified by the Date parameter is copied to the result.[/code]
так что будет таки "28 или 29 февраля в зависимости от года"


 
ZEE ©   (2003-09-18 10:50) [8]

поправка с правильной расстановкой тегов :)
из хелпа:
function IncMonth(const Date: TDateTime; NumberOfMonths: Integer = 1): TDateTime;
...
If the input day of month is greater than the last day of the resulting month, the day is set to the last day of the resulting month. The time of day specified by the Date parameter is copied to the result.

так что будет таки "28 или 29 февраля в зависимости от года"


 
Anatoly Podgoretsky ©   (2003-09-18 11:59) [9]

31 марта - 1 месяц
30 марта - 1 месяц
29 марта - 1 месяц
28 марта - 1 месяц
28 февраля - 1 месяц

И повторно вопрос от Reindeer Moss Eater © (18.09.03 09:53) [3], при том сначла вдуматься в вопрос, не сколько даст эта функция, а сколько должно получиться.



Страницы: 1 вся ветка

Текущий архив: 2003.09.29;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.014 c
3-96081
AlexMan
2003-09-10 07:46
2003.09.29
IBServer under W98


3-96068
Senator
2003-09-10 09:52
2003.09.29
Restore


4-96479
McSimm2
2003-07-28 10:11
2003.09.29
GetWindowText


14-96393
Zhirnov Maxim
2003-09-10 15:21
2003.09.29
RealTime Operation System


3-96059
demonyator
2003-08-29 20:43
2003.09.29
Округление результата SQL запроса