如何求日期?(50分)

  • 主题发起人 主题发起人 hyc991
  • 开始时间 开始时间
H

hyc991

Unregistered / Unconfirmed
GUEST, unregistred user!
是否有以函数可求当前日期的前一天日期,即2001-11-1,求2001-10-31?如没有如何编程?
 
var
Yesterday: TDate;
begin
Yesterday:=date-1;
end;
 
可以仿LOTUS NOTES中写一个函数叫function justtime(data:Tdatatime;n,y,r:integer):Tdatatime
其中n:要改变的年份,y,要改变的月份,r,要改变的月份,正的表示向前推,负的表示往回
推。我写过一个,但一时不知放哪去了,但思路是这个样子的。
 
我自己有個公共pas文件﹐其中有這類函數﹐
寫mail給我. williamgui@21cn.com
 
JSP中获得当前时间
[% public String getTime()
{java.util.Date now = new java.util.Date();
int dd = now.getDate();
int mt = now.getMonth() + 1;
int yy = now.getYear();
yy=(yy [ 1000) ? yy + 1900 : yy;
String mydate=String.valueOf(yy) +"年"+String.valueOf(mt) +"月"+String.valueOf(dd) +"日";
int hh = now.getHours();
int mm = now.getMinutes();
int ss = now.getSeconds();
String mytime=mydate+String.valueO f(hh)+"时"+String.valueOf (mm)+"分"+String.valueOf (ss)+"秒";
return mytime;
} %]
[%=getTime()%]
做一下判断即可!
 
////////////////////////////////////////////////////////////////
// Author: WilliamGui //
// Modify Date: 2001-04-20 //
// Visit my personal WebSite: http://21sparrow.yeah.net //
////////////////////////////////////////////////////////////////
unit wgpubcode;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ShellAPI;
{-$define _ENG}
{$DEFINE _BG}
{-$define _BIG5}
{--- Common Function ---}
//About String Function
function StrRepeat(AProcessString: string;
n: integer): string;
const
{$IFDEF _BG}
UNITAGE_STR: string = 'Ǫ°ÛÊ°ÒÚǪ°ÛÊ°ÍòǪ°ÛÊ°Ôª½Ç·Ö';
UPPER_STR: string = 'ÁãÒ¼·¡²ÎËÁÎé½Æâ°Æ¾Á';
CURRENCY_UOM_STR: string = 'Ôª½Ç·Ö';
CURRENCY_SUFFIX_STR: string = 'ÕûÕý¸º';
{$ENDIF}
{$IFDEF _BIG5}
UNITAGE_STR: string = '¥a¨Õ¬B»õ¥a¨Õ¬BÉE¥a¨Õ¬B¤¸¨¤¤À';
UPPER_STR: string = '¹s³ü¶L°Ñ¸v¥î³°¬m®Ã¨h';
CURRENCY_UOM_STR: string = '¤¸¨¤¤À';
CURRENCY_SUFFIX_STR: string = '¾ã¥¿­t';
{$ENDIF}
//{$ifdef _BG or _BIG5}
{$IFDEF _BG}
function CurrencyToChinese(ACurrency: Currency;
Default: string = ''): string;
{$ENDIF}
//About Datetime Function
function GetItYear(AProcessDate: TDate): integer;
function GetItMonth(AProcessDate: TDate): integer;
function GetItDay(AProcessDate: TDate): integer;
function GetYear: integer;
function GetMonth: integer;
function GetDay: integer;
function GetFirstDayOfMonth(AProcessDate: TDate): TDate;
function GetLastDayOfMonth(AProcessDate: TDate): TDate;
function GetDayCountInMonth(AProcessDate: TDate): integer;
function GetFirstDayOfPriorMonth(AProcessDate: TDate): TDate;
function GetLastDayOfPriorMonth(AProcessDate: TDate): TDate;
function GetDayCountInPriorMonth(AProcessDate: TDate): integer;
function GetFirstDayOfNextMonth(AProcessDate: TDate): TDate;
function GetLastDayOfNextMonth(AProcessDate: TDate): TDate;
function GetDayCountInNextMonth(AProcessDate: TDate): integer;
{--- MessageBox ---}
const
{$IFDEF _ENG}
TIP_STRING = 'Tip';
WARNING_STRING = 'Warning';
ERROR_STRING = 'Error';
CONFIRM_STRING = 'Confirm';
QUERY_DELETE_STRING = ' Are you sure to delete this record(Y/N)? ';
QUERY_SAVE_STRING = ' Are you save it(Y/N)? ';
QUERY_EXIT_STRING = ' Are you sure to exit(Y/N)? ';
NOT_DEVELOP_FINISH_STRING = ' The function is developing ...... ';
{$ENDIF}
{$IFDEF _BG}
TIP_STRING = 'Ìáʾ';
WARNING_STRING = '¾¯¸æ';
ERROR_STRING = '´íÎó';
CONFIRM_STRING = 'È·ÈÏ';
QUERY_DELETE_STRING = ' ÊÇ·ñҪɾ³ýÕâÌõ¼Ç¼(Y/N)? ';
QUERY_SAVE_STRING = ' ÊÇ·ñ´æÅÌ(Y/N)? ';
QUERY_EXIT_STRING = ' ÊÇ·ñÕæµÃÒªÍ˳ö(Y/N)? ';
NOT_DEVELOP_FINISH_STRING = ' ¸Ã¹¦ÄÜ»¹ÔÚ¿ª·¢ÖÐ...... ';
{$ENDIF}
{$IFDEF _BIG5}
TIP_STRING = '´£¥Ü';
WARNING_STRING = 'ĵ§i';
ERROR_STRING = '¿ù»~';
CONFIRM_STRING = '½T»{';
QUERY_DELETE_STRING = ' ¬O§_­n§R°£³o±ø°O¿ý(Y/N)? ';
QUERY_SAVE_STRING = ' ¬O§_¦s½L(Y/N)? ';
QUERY_EXIT_STRING = ' ¬O§_¯u±o­n°h¥X(Y/N)? ';
NOT_DEVELOP_FINISH_STRING = ' ¸Ó¥/¯àÁÙ¦b¶}µo¤¤...... ';
{$ENDIF}
{ New MessageBox 2001/08/01}
function InfoMsgBox(AInformationString: string): integer;
function WarningMsgBox(AWarningString: string): integer;
function ErrorMsgBox(AErrorString: string): integer;
function QueryMsgBox(AQuestionString: string;
ADefaultButton: integer = 1): integer;
function ConfMsgBox(AQuestionString: string;
ADefaultButton: integer = 1): integer;
function QueryDelMsgBox(ADeleteString: string = QUERY_DELETE_STRING): integer;
function QuerySaveMsgBox(ASaveString: string = QUERY_SAVE_STRING): integer;
function QueryExitMsgBox(AExitString: string = QUERY_EXIT_STRING): integer;
function NotDevelopFinishMsgBox(ANotDevelopFinishString: string = NOT_DEVELOP_FINISH_STRING): integer;
{--- Windows ---}
function OpenWindow(var AForm: TForm;
ATFormClass: TFormClass;
AOwner: TComponent;
AOpenMethod: integer = 1): integer;
{--- Voice ---}
type
TBleepType = (vOK, vInterrupt, vError);
procedure Bleep(BleepType: TBleepType);
//·¢³öÉùÒô
procedure Sound(dFreq:do
uble;
wLong: word);
//·¢³ö¸÷Òô½×ÉùÒô
{ #49,#97: sound(261.7,400);
C
#50,#98: sound(293.7,400);
D
#51,#99: sound(329.6,400);
E
#52,#100: sound(349.2,400);
F
#53,#101: sound(392.0,400);
G
#54,#102: sound(440.0,400);
A
#55,#103: sound(493.9,400);
B }
{--- About System ---}
function DiskInDrive(Drive: Char): Boolean;
//Çý¶¯Æ÷ÊÇ·ñ×¼±¸ºÃ
function GetWindowsTempPath: string;
{--- About Network ---}
function GetLoginName: string;
{--- Code ---}
implementation
function StrRepeat(AProcessString: string;
n: integer): string;
var
i: integer;
TempVar: string;
begin
TempVar := '';
for i := 1 to ndo
begin
TempVar := TempVar + AProcessString;
end;
Result := TempVar;
end;

{$IFNDEF _ENG}
function CurrencyToChinese(ACurrency: Currency;
Default: string = ''): string;
function RightStr(S: string;
N: Integer): string;
// ·µ»ØÖ¸¶¨×Ö·û´®µÄÓÒ±ß
N ¸ö×Ö·û
var
Start: Integer;
begin
Start := Length(S) - N + 1;
if Start <= Length(S) then
Result := Copy(S, Start, N)
else
Result := '';
end;
var
LowStr: string;
// &amp;ETH;&amp;iexcl;&amp;ETH;&amp;acute;&amp;frac12;&amp;eth;&amp;para;&amp;icirc;×&amp;Ouml;·&amp;ucirc;&amp;acute;&amp;reg;
CurrentChar: Char;
// &amp;micro;±&amp;Ccedil;°&amp;Ecirc;&amp;yacute;&amp;Ouml;&amp;micro;&amp;micro;&amp;Auml;ASCII&amp;Acirc;&amp;euml;
CurrentNum: Integer;
// &amp;micro;±&amp;Ccedil;°&amp;Ecirc;&amp;yacute;&amp;Ouml;&amp;micro;
UpperStr, UnitageChar: string[4];
// &amp;acute;ó&amp;ETH;&amp;acute;&amp;frac12;&amp;eth;&amp;para;&amp;icirc;×&amp;Ouml;·&amp;ucirc;&amp;acute;&amp;reg;&amp;ordm;&amp;Iacute;&amp;frac12;&amp;eth;&amp;para;&amp;icirc;&amp;micro;&amp;yen;&amp;Icirc;&amp;raquo;×&amp;Ouml;·&amp;ucirc;&amp;acute;&amp;reg;
CurrentPos, UnitagePos: Integer;
// &amp;Euml;÷&amp;Ograve;&amp;yacute;
begin
// Is Zero?
if ACurrency = 0 then
begin
Result := Default;
Exit;
end;
Result := '';
FmtStr(LowStr, '%15.2f', [ACurrency]);
// Convert to string
LowStr := Trim(LowStr);
if ACurrency < 0 then
LowStr := Copy(LowStr, 2, Length(LowStr) - 1);
// &amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;Ecirc;&amp;Ccedil;&amp;cedil;&amp;ordm;&amp;Ouml;&amp;micro;&amp;pound;&amp;not;&amp;Iuml;&amp;Egrave;°&amp;Ntilde;×&amp;Ouml;·&amp;ucirc;&amp;acute;&amp;reg;&amp;Agrave;&amp;iuml;&amp;micro;&amp;Auml;&amp;Auml;&amp;Ccedil;&amp;cedil;&amp;ouml;&amp;cedil;&amp;ordm;&amp;ordm;&amp;Aring;&amp;Egrave;&amp;yen;&amp;micro;&amp;ocirc;
CurrentPos := 1;
UnitagePos := 15 - Length(LowStr);
while UnitagePos < 14do
begin
CurrentChar := LowStr[CurrentPos];
// &amp;Egrave;&amp;iexcl;&amp;micro;±&amp;Ccedil;°&amp;Icirc;&amp;raquo;&amp;Ecirc;&amp;yacute;×&amp;Ouml;
if (CurrentChar > '9') or (CurrentChar < '0') then
begin
// &amp;Egrave;&amp;iexcl;&amp;micro;&amp;frac12;&amp;micro;&amp;Auml;×&amp;Ouml;·&amp;ucirc;&amp;iquest;&amp;Eacute;&amp;Auml;&amp;Uuml;&amp;sup2;&amp;raquo;&amp;Ecirc;&amp;Ccedil;&amp;Ecirc;&amp;yacute;×&amp;Ouml;&amp;pound;¨±&amp;Egrave;&amp;Egrave;&amp;ccedil;&amp;Euml;&amp;micro;&amp;Ecirc;&amp;Ccedil;&amp;ETH;&amp;iexcl;&amp;Ecirc;&amp;yacute;&amp;micro;&amp;atilde;&amp;pound;&amp;copy;
Inc(CurrentPos);
Continue;
end;
CurrentNum := Ord(CurrentChar) - Ord('0');
// &amp;Egrave;&amp;iexcl;&amp;micro;±&amp;Ccedil;°&amp;Ecirc;&amp;yacute;×&amp;Ouml;&amp;micro;&amp;Auml;&amp;Ouml;&amp;micro;
UpperStr := Copy(UPPER_STR, (CurrentNum shl 1) + 1, 2);
// &amp;Egrave;&amp;iexcl;&amp;Iuml;à&amp;Oacute;&amp;brvbar;&amp;micro;&amp;Auml;&amp;acute;ó&amp;ETH;&amp;acute;&amp;Ouml;&amp;ETH;&amp;Icirc;&amp;Auml;
UnitageChar := Copy(UNITAGE_STR, (UnitagePos shl 1) + 1, 2);
// &amp;Iuml;à&amp;Oacute;&amp;brvbar;&amp;micro;&amp;Auml;&amp;micro;&amp;yen;&amp;Icirc;&amp;raquo;
if (CurrentNum <> 0) then
begin
// &amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;Egrave;&amp;iexcl;&amp;micro;&amp;Atilde;&amp;micro;&amp;Auml;&amp;Ecirc;&amp;yacute;×&amp;Ouml;&amp;sup2;&amp;raquo;&amp;Ecirc;&amp;Ccedil;&amp;Aacute;&amp;atilde;&amp;pound;&amp;not;&amp;ordm;&amp;Uuml;&amp;frac14;ò&amp;micro;&amp;yen;&amp;pound;&amp;not;&amp;Ocirc;&amp;Uacute;×&amp;Ouml;·&amp;ucirc;&amp;acute;&amp;reg;&amp;ordm;ó&amp;Atilde;&amp;aelig;&amp;Igrave;í&amp;frac14;&amp;Oacute;&amp;Eacute;&amp;Iuml;&amp;Ecirc;&amp;yacute;&amp;Ouml;&amp;micro;&amp;ordm;&amp;Iacute;&amp;micro;&amp;yen;&amp;Icirc;&amp;raquo;&amp;frac34;&amp;Iacute;&amp;ETH;&amp;ETH;&amp;Aacute;&amp;Euml;
Result := Result + UpperStr + UnitageChar;
Inc(UnitagePos);
Inc(CurrentPos);
Continue;
end;
if RightStr(Result, 2) <> copy(UPPER_STR, 1, 2) then
Result := Result + copy(UPPER_STR, 1, 2);
// &amp;Ecirc;&amp;Ccedil;&amp;Aacute;&amp;atilde;&amp;frac34;&amp;Iacute;&amp;Acirc;é·&amp;sup3;&amp;Aacute;&amp;Euml;&amp;pound;&amp;not;&amp;Iuml;&amp;Egrave;&amp;iquest;&amp;acute;&amp;iquest;&amp;acute;&amp;Ecirc;&amp;Ccedil;&amp;sup2;&amp;raquo;&amp;Ecirc;&amp;Ccedil;&amp;Ouml;&amp;Oslash;&amp;cedil;&amp;acute;&amp;Aacute;&amp;atilde;&amp;pound;&amp;not;&amp;sup2;&amp;raquo;&amp;Ecirc;&amp;Ccedil;&amp;frac34;&amp;Iacute;&amp;Iuml;&amp;Egrave;&amp;frac14;&amp;Oacute;&amp;Ograve;&amp;raquo;&amp;cedil;&amp;ouml;'&amp;Aacute;&amp;atilde;'&amp;Ocirc;&amp;Ugrave;&amp;Euml;&amp;micro;
{ &amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;Ecirc;&amp;Ccedil;&amp;Aacute;&amp;atilde;&amp;Ccedil;&amp;Ograve;&amp;Oacute;&amp;Ouml;&amp;Otilde;&amp;yacute;&amp;ordm;&amp;Atilde;&amp;Ocirc;&amp;Uacute;'&amp;Ograve;&amp;Uacute;'&amp;iexcl;&amp;cent;'&amp;Iacute;ò'&amp;iexcl;&amp;cent;'&amp;Ocirc;&amp;ordf;'&amp;Otilde;&amp;acirc;&amp;Egrave;&amp;yacute;&amp;cedil;&amp;ouml;&amp;Icirc;&amp;raquo;&amp;Ouml;&amp;Atilde;&amp;Eacute;&amp;Iuml;&amp;pound;&amp;not;&amp;frac34;&amp;Iacute;&amp;iexcl;&amp;shy;&amp;iexcl;&amp;shy;
&amp;acute;ó&amp;frac14;&amp;Ograve;&amp;para;&amp;frac14;&amp;Ccedil;&amp;aring;&amp;sup3;&amp;thorn;&amp;pound;&amp;not;&amp;Atilde;&amp;raquo;&amp;Oacute;&amp;ETH;'&amp;sup2;&amp;Icirc;&amp;Ecirc;°&amp;Aacute;&amp;atilde;&amp;Ocirc;&amp;ordf;'&amp;raquo;ò'·&amp;iexcl;&amp;Ecirc;°&amp;Aacute;&amp;atilde;&amp;Iacute;ò&amp;frac34;&amp;Aacute;&amp;Ccedil;&amp;ordf;'&amp;Otilde;&amp;acirc;&amp;Ouml;&amp;Ouml;&amp;Euml;&amp;micro;·¨&amp;pound;&amp;not;&amp;Ouml;&amp;raquo;&amp;Oacute;&amp;ETH;
'&amp;sup2;&amp;Icirc;&amp;Ecirc;°&amp;Ocirc;&amp;ordf;'&amp;ordm;&amp;Iacute;'·&amp;iexcl;&amp;Ecirc;°&amp;Iacute;ò&amp;frac34;&amp;Aacute;&amp;Ccedil;&amp;ordf;'&amp;pound;&amp;not;&amp;Ograve;ò&amp;acute;&amp;Euml;&amp;Ograve;&amp;ordf;&amp;Eacute;&amp;frac34;&amp;Egrave;&amp;yen;&amp;Eacute;&amp;Iuml;&amp;Atilde;&amp;aelig;&amp;Auml;&amp;Ccedil;&amp;frac34;&amp;auml;&amp;acute;ú&amp;Acirc;&amp;euml;&amp;Euml;ù&amp;frac14;&amp;Oacute;&amp;micro;&amp;Auml;'&amp;Aacute;&amp;atilde;'×&amp;Ouml;·&amp;ucirc;
}
if (UnitageChar = copy(UNITAGE_STR, 7, 2)) or (UnitageChar = copy(UNITAGE_STR, 15, 2)) or (UnitageChar = '¤&amp;cedil;') then
begin
Delete(Result, Length(Result) - 1, 2);
if RightStr(Result, 2) <> copy(UNITAGE_STR, 7, 2) then
Result := Result + UnitageChar;
// &amp;raquo;&amp;sup1;&amp;Ograve;&amp;ordf;&amp;iquest;&amp;acute;&amp;iquest;&amp;acute;&amp;Ccedil;°&amp;Ograve;&amp;raquo;&amp;Icirc;&amp;raquo;&amp;Ecirc;&amp;Ccedil;&amp;sup2;&amp;raquo;&amp;Ecirc;&amp;Ccedil;'&amp;Ograve;&amp;Uacute;'&amp;Icirc;&amp;raquo;&amp;pound;&amp;not;&amp;Ecirc;&amp;Ccedil;&amp;frac34;&amp;Iacute;&amp;sup2;&amp;raquo;&amp;frac14;&amp;Oacute;&amp;micro;&amp;yen;&amp;Icirc;&amp;raquo;&amp;Aacute;&amp;Euml;
Result := Result + copy(UPPER_STR, 1, 2);
end;
Inc(UnitagePos);
Inc(CurrentPos);
end;
if RightStr(Result, 2) = copy(UPPER_STR, 1, 2) then
Result := Copy(Result, 1, Length(Result) - 2);
// &amp;Ntilde;&amp;frac12;&amp;pound;&amp;not;&amp;Ouml;&amp;Otilde;&amp;Oacute;&amp;Uacute;×&amp;ordf;&amp;raquo;&amp;raquo;&amp;Iacute;ê&amp;Aacute;&amp;Euml;&amp;pound;&amp;not;±&amp;eth;&amp;Atilde;&amp;brvbar;&amp;pound;&amp;not;&amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;frac12;á&amp;sup1;&amp;ucirc;&amp;micro;&amp;Auml;&amp;Auml;&amp;copy;&amp;Icirc;&amp;sup2;&amp;Ecirc;&amp;Ccedil;'&amp;Aacute;&amp;atilde;'&amp;raquo;&amp;sup1;&amp;Ograve;&amp;ordf;&amp;Eacute;&amp;frac34;&amp;Egrave;&amp;yen;&amp;Euml;ü
if Copy(Result, 1, 2) = copy(UPPER_STR, 1, 2) then
Result := Copy(Result, 3, Length(Result) - 2);
// &amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;frac12;á&amp;sup1;&amp;ucirc;&amp;micro;&amp;Auml;&amp;iquest;&amp;ordf;&amp;Ecirc;&amp;frac14;&amp;frac34;&amp;Iacute;&amp;Ecirc;&amp;Ccedil;&amp;Aacute;&amp;atilde;&amp;pound;&amp;not;&amp;Ograve;&amp;sup2;&amp;Ograve;&amp;ordf;&amp;Eacute;&amp;frac34;&amp;sup3;&amp;yacute;&amp;Euml;ü
if RightStr(Result, 2) = copy(CURRENCY_UOM_STR, 3, 2) then
Result := Result + copy(CURRENCY_SUFFIX_STR, 3, 2) // &amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;frac12;á&amp;sup1;&amp;ucirc;&amp;Otilde;&amp;yacute;&amp;ordm;&amp;Atilde;&amp;Ecirc;&amp;Ccedil;'XXXX&amp;frac12;&amp;Ccedil;'&amp;pound;&amp;not;°&amp;acute;&amp;Iuml;°&amp;sup1;&amp;szlig;&amp;Oacute;&amp;brvbar;&amp;cedil;&amp;Atilde;&amp;frac14;&amp;Oacute;&amp;Eacute;&amp;Iuml;&amp;Ograve;&amp;raquo;&amp;cedil;&amp;ouml;'XXXX&amp;frac12;&amp;Ccedil;&amp;Otilde;&amp;yacute;'
else
if RightStr(Result, 2) <> copy(CURRENCY_UOM_STR, 5, 2) then
Result := Result + copy(CURRENCY_SUFFIX_STR, 1, 2);
// &amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;frac12;á&amp;sup1;&amp;ucirc;&amp;sup2;&amp;raquo;&amp;Ecirc;&amp;Ccedil;'XXXX·&amp;Ouml;&amp;pound;&amp;not;&amp;frac34;&amp;Iacute;&amp;Ograve;&amp;ordf;&amp;frac14;&amp;Oacute;&amp;Eacute;&amp;Iuml;&amp;Ograve;&amp;raquo;&amp;cedil;&amp;ouml;'&amp;Otilde;&amp;ucirc;'×&amp;Ouml;
if Copy(Result, 1, 2) = copy(CURRENCY_UOM_STR, 1, 2) then
Result := RightStr(Result, Length(Result) - 4);
// &amp;raquo;&amp;sup1;&amp;Oacute;&amp;ETH;&amp;Ograve;&amp;raquo;&amp;cedil;&amp;ouml;&amp;ETH;&amp;iexcl;&amp;Icirc;&amp;Ecirc;&amp;Igrave;&amp;acirc;&amp;pound;&amp;not;&amp;frac34;&amp;Iacute;&amp;Ecirc;&amp;Ccedil;......
if ACurrency < 0 then
Result := copy(CURRENCY_SUFFIX_STR, 5, 2) + Result;
// ×&amp;icirc;&amp;ordm;ó&amp;pound;&amp;not;&amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;Ecirc;&amp;Ccedil;&amp;cedil;&amp;ordm;&amp;Ouml;&amp;micro;&amp;raquo;&amp;sup1;&amp;Ograve;&amp;ordf;&amp;frac14;&amp;Oacute;&amp;Eacute;&amp;Iuml;&amp;Ograve;&amp;raquo;&amp;cedil;&amp;ouml;'&amp;cedil;&amp;ordm;'
end;
{$ENDIF}
function InfoMsgBox(AInformationString: string): integer;
begin
Result := MessageBox(GetActiveWindow, PChar(AInformationString), PChar(TIP_STRING), MB_ICONINFORMATION + MB_OK);
end;

function WarningMsgBox(AWarningString: string): integer;
begin
Result := MessageBox(GetActiveWindow, PChar(AWarningString), PChar(WARNING_STRING), MB_ICONWARNING + MB_OK);
end;

function ErrorMsgBox(AErrorString: string): integer;
begin
Result := MessageBox(GetActiveWindow, PChar(AErrorString), PChar(ERROR_STRING), MB_ICONERROR + MB_OK);
end;

function QueryMsgBox(AQuestionString: string;
ADefaultButton: integer = 1): integer;
begin
if ADefaultButton = 2 then
Result := MessageBox(GetActiveWindow, PChar(AQuestionString), PChar(CONFIRM_STRING), MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON2)
else
Result := MessageBox(GetActiveWindow, PChar(AQuestionString), PChar(CONFIRM_STRING), MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON1);
end;

function ConfMsgBox(AQuestionString: string;
ADefaultButton: integer = 1): integer;
begin
Result := QueryMsgBox(AQuestionString, ADefaultButton);
end;

function QueryDelMsgBox(ADeleteString: string = QUERY_DELETE_STRING): integer;
begin
Result := QueryMsgBox(ADeleteString, 2);
end;

function QuerySaveMsgBox(ASaveString: string = QUERY_SAVE_STRING): integer;
begin
Result := QueryMsgBox(ASaveString);
end;

function QueryExitMsgBox(AExitString: string = QUERY_EXIT_STRING): integer;
begin
Result := QueryMsgBox(AExitString, 2);
end;

function NotDevelopFinishMsgBox(ANotDevelopFinishString: string = NOT_DEVELOP_FINISH_STRING): integer;
begin
Result := InfoMsgBox(ANotDevelopFinishString);
end;

procedure AsmShutUp;
pascal;
begin
asm
In AL, $61 { Stop Bleeping }
And AL, $FC
Out $61, AL
end;
end;

procedure AsmBeep(Freq: Word);
pascal;
label
Skip;
begin
asm
Push BX
In AL, $61
Mov BL, AL
And AL, 3
Jne Skip
//Jne @Skip
Mov AL, BL
Or AL, 3
Out $61, AL
Mov AL, $B6
Out $43, AL
Skip: Mov AX, Freq
//@Skip: Mov AX, Freq
Out $42, AL
Mov AL, AH
Out $42, AL
Pop BX
end;
end;

procedure HardBleep(Freq: Word;
MSecs: Integer);
var
FirstTickCount: DWord;
begin
if (Freq >= 20) and (Freq <= 5000) then
begin
AsmBeep(Word(1193181 div LongInt(Freq)));
if MSecs >= 0 then
begin
FirstTickCount := GetTickCount;
repeat
if MSecs > 1000 then
Application.ProcessMessages;
//Until ((GetTickCount-FirstTickCount)>LongInt(MSecs));
until (LongInt(GetTickCount - FirstTickCount) > LongInt(MSecs));
AsmShutUp;
end;
end;
end;
var
SysWinNT: Boolean;
proceduredo
Bleep(Freq: Word;
MSecs: Integer);
begin
if SysWinNT then
Windows.Beep(Freq, MSecs)
else
HardBleep(Freq, MSecs);
end;
{ Added to help counter the effects ofdo
Bleep (Freq, -1).
If you are producing a tone, &amp;
you want to stop withoutdo
ing another Bleep, call this procedure }
//Procedure ShutUp;
//begin
// If SysWinNT then
Windows.Beep(1, 0) else
AsmShutUp;
//end;

procedure Bleep(BleepType: TBleepType);
begin
case BleepType of
vOK: begin
do
Bleep(1047, 100);
do
Bleep(1109, 100);
do
Bleep(1175, 100);
end;
vInterrupt: begin
do
Bleep(2093, 100);
do
Bleep(1976, 100);
do
Bleep(1857, 100);
end;
vError: begin
do
Bleep(80, 500);
end;
end;
end;

procedure InitSysType;
var
VersionInfo: TOSVersionInfo;
begin
VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);
GetVersionEx(VersionInfo);
SysWinNT := VersionInfo.dwPlatformID = VER_PLATFORM_WIN32_NT;
end;

procedure Sound(dFreq:do
uble;
wLong: word);
var
wFreq: word;
begin
wFreq := round(1192576 / dFreq);
asm
push ax
push bx
push cx
push dx
push di
mov al,0b6h
out 43h,al
mov dx,12h
mov ax,wFreq
out 42h,al
mov al,ah
out 42h,al
in al,61h
mov ah,al
or al,3
out 61h,al
@wait1:mov cx,wLong
@delay:loop @delay
dec bx
jnz @wait1
mov al,0b6h
out 43h,al
mov al,ah
out 61h,al
pop di
pop dx
pop cx
pop bx
pop ax
end;
end;

function DiskInDrive(Drive: Char): Boolean;
var
ErrorMode: word;
begin
{ make it upper case }
if Drive in ['a'..'z'] then
Dec(Drive, $20);
{ make sure it's a letter }
if not (Drive in ['A'..'Z']) then
raise EConvertError.Create('Not a valid drive ID');
{ turn off critical errors }
ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
try
{ drive 1 = a, 2 = b, 3 = c, etc. }
if DiskSize(Ord(Drive) - $40) = -1 then
Result := False
else
Result := True;
finally
{ restore old error mode }
SetErrorMode(ErrorMode);
end;
end;

function GetWindowsTempPath: string;
var
TempVar1: array[0..100] of Char;
begin
GetTempPath(100, TempVar1);
Result := trim(string(TempVar1));
end;

function GetLoginName: string;
var
lpBuffer: array[0..100] of Char;
nSize: DWord;
begin
nSize := Sizeof(lpBuffer);
GetUserName(lpBuffer, nSize);
Result := trim(lpBuffer);
end;

function GetItYear(AProcessDate: TDate): integer;
var
TempVar1, TempVar2, TempVar3: word;
begin
decodedate(AProcessDate, TempVar1, TempVar2, TempVar3);
Result := TempVar1;
end;

function GetItMonth(AProcessDate: TDate): integer;
var
TempVar1, TempVar2, TempVar3: word;
begin
decodedate(AProcessDate, TempVar1, TempVar2, TempVar3);
Result := TempVar2;
end;

function GetItDay(AProcessDate: TDate): integer;
var
TempVar1, TempVar2, TempVar3: word;
begin
decodedate(AProcessDate, TempVar1, TempVar2, TempVar3);
Result := TempVar3;
end;

function GetYear: integer;
begin
Result := GetItYear(Date);
end;

function GetMonth: integer;
begin
Result := GetItMonth(Date);
end;

function GetDay: integer;
begin
Result := GetItDay(Date);
end;

function GetFirstDayOfMonth(AProcessDate: TDate): TDate;
var
TempVar1, TempVar2, TempVar3: word;
begin
DecodeDate(AProcessDate, TempVar1, TempVar2, TempVar3);
Result := EncodeDate(TempVar1, TempVar2, 1);
end;

function GetLastDayOfMonth(AProcessDate: TDate): TDate;
var
TempVar1, TempVar2, TempVar3: word;
begin
DecodeDate(AProcessDate, TempVar1, TempVar2, TempVar3);
if (TempVar2 = 12) then
Result := EncodeDate(TempVar1 + 1, 1, 1) - 1
else
Result := EncodeDate(TempVar1, TempVar2 + 1, 1) - 1;
end;

function GetDayCountInMonth(AProcessDate: TDate): integer;
begin
Result := GetItDay(GetLastDayOfMonth(AProcessDate));
end;

function GetFirstDayOfPriorMonth(AProcessDate: TDate): TDate;
var
TempVar1, TempVar2, TempVar3: word;
begin
DecodeDate(AProcessDate, TempVar1, TempVar2, TempVar3);
if TempVar2 = 1 then
Result := EncodeDate(TempVar1 - 1, 12, 1)
else
Result := EncodeDate(TempVar1, TempVar2 - 1, 1);
end;

function GetLastDayOfPriorMonth(AProcessDate: TDate): TDate;
var
TempVar1, TempVar2, TempVar3: word;
begin
DecodeDate(AProcessDate, TempVar1, TempVar2, TempVar3);
if TempVar2 = 1 then
begin
Result := EncodeDate(TempVar1 - 1, 12, 31);
end
else
begin
Result := EncodeDate(TempVar1, TempVar2, 1) - 1;
end;
end;

function GetDayCountInPriorMonth(AProcessDate: TDate): integer;
begin
Result := GetItDay(GetLastDayOfPriorMonth(AProcessDate));
end;

function GetFirstDayOfNextMonth(AProcessDate: TDate): TDate;
var
TempVar1, TempVar2, TempVar3: word;
begin
DecodeDate(AProcessDate, TempVar1, TempVar2, TempVar3);
if (TempVar2 = 12) then
Result := EncodeDate(TempVar1 + 1, 1, 1)
else
Result := EncodeDate(TempVar1, TempVar2 + 1, 1);
end;

function GetLastDayOfNextMonth(AProcessDate: TDate): TDate;
var
TempVar1, TempVar2, TempVar3: word;
begin
DecodeDate(AProcessDate, TempVar1, TempVar2, TempVar3);
case TempVar2 of
11: Result := EncodeDate(TempVar1, 12, 31);
12: Result := EncodeDate(TempVar1 + 1, 1, 31);
else
Result := EncodeDate(TempVar1, TempVar2 + 2, 1) - 1;
end;
end;

function GetDayCountInNextMonth(AProcessDate: TDate): integer;
begin
Result := GetItDay(GetLastDayOfNextMonth(AProcessDate));
end;

function OpenWindow(var AForm: TForm;
ATFormClass: TFormClass;
AOwner: TComponent;
AOpenMethod: integer = 1): integer;
begin
AForm := ATFormClass.Create(AOwner);
//AForm.Create(AOwner);
// .CreateParented(AOwner) ;
if AOpenMethod = 0 then
begin
try
AForm.Show;
Result := 0;
except
AForm.free;
Result := -1;
end;
end
else
begin
try
Result := AForm.ShowModal;
AForm.free;
except
Result := -1;
end;
end;
end;

{--- Initialization ---}
initialization
InitSysType;
end.
 
date-1
就行,偏有人搞那么麻烦,好几百行程序
 
倒,楼上那位老大也太夸张了
 
我在写每月销售明细报表中习惯这样做:
报表要求是:求出每天的进销存情况;
假若要求2月份:我将最后的日期定为:'2001/3/1'
for i:=1 to strtodate('2001/3/1')-1do
begin

end;
 
[red]拜托!
这里是Jsp版![/red]
to hyc991:
你需要的是一个java.util.Calendar 类。
Locale locale=Locale.getDefault();
TomeZone timeZone=TimeZone.getDefault();
Calendar cal=Calendar.getInstance(timeZone,locale);
cal.set(Calendar.DAY_OF_MONTH,cal.get(Calendar.DAY_OF_MONTH)-1);
现在cal里面的就是前一天了.
如果你想要java.util.Date,再
java.util.Date d = cal.getTime();
如果你要java.sql.Date,再
java.sql.Date sqld = d.getTime();
 
接受答案了.
 
后退
顶部