星期一, 11月 14, 2011

取得當日開始及最後時間

//******************************************************************************
//* GetDayStartDT: 取得當日開始時間AM 00:00:01:00                              *
//******************************************************************************
function mDayStartDT(tmpDT: TDateTime): TDateTime;
var
  wYear, wMonth, wDay: WORD;
begin
  DecodeDate(tmpDT, wYear, wMonth, wDay);
  Result := EncodeDate(wYear, wMonth, wDay)+
            EncodeTime(0, 0, 0, 0);
end;
//******************************************************************************
//* GetDayEndDT: 取得當日結束時間PM 23:59:59:00                                *
//******************************************************************************
function mDayEndDT(tmpDT: TDateTime): TDateTime;
var
  wYear, wMonth, wDay: WORD;
begin
  DecodeDate(tmpDT, wYear, wMonth, wDay);
  Result := EncodeDate(wYear, wMonth, wDay)+
            EncodeTime(23, 59, 59, 0);
end;