xp計算不正確 |
缺席
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
function TForm1.OldYearCnt(birth : string):integer;
var BYear, BMonth, BDay: Integer; YearOld: Integer; Year, Month, Day : Word; tst_Year, tst_Month, tst_Day :word; world_date1 : string; Tst_DateTime: TDateTime; begin if birth = '' then begin result := 0; exit; end; try Tst_DateTime := strtodatetime(birth); except result := 0; exit; end; DecodeDate(Tst_DateTime, tst_Year, tst_Month, tst_Day); YearOld := 0; DecodeDate(now, Year, Month, Day); world_date1 := birth; BYear := StrToInt(copy(world_date1, 1, 4)); delete(world_date1,1,5); BMonth := StrToInt(copy(world_date1, 1, 2)); delete(world_date1,1,3); BDay := StrToInt(world_date1); if (Month > BMonth) and (Year >= BYear) then YearOld := Year - BYear; if (Day >= BDay) and (Month = BMonth) and (Year >= BYear) then YearOld := Year - BYear; if (Day < BDay) and (Month = BMonth) and (Year >= BYear) then YearOld := Year - BYear-1; if (Month < BMonth) and (Year >= BYear) then YearOld := Year - BYear -1; result := YearOld; end;
------
努力會更接近成功 編輯記錄
pceyes 重新編輯於 2007-06-26 08:03:48, 註解 無‧
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |