Board index » delphi » How to Compare/Change ** Date **

How to Compare/Change ** Date **

1. I need compare two Date variable to find out how many days between
two date.

2. How to set the date (e.g.: Date + 7 days)

Sorry for above question, it seems so easy but I cannot found in some
manual, and I try many work also can't do it.

Henry Cheng

 

Re:How to Compare/Change ** Date **


Quote
>1. I need compare two Date variable to find out how many days between
>two date.

NumberOfDays:=trunc(Date2) - trunc(Date1);

Quote
>2. How to set the date (e.g.: Date + 7 days)

Date1:=Date1 + 7;

Best Regards
Fernando Dias

Re:How to Compare/Change ** Date **


Dates are stored internally in floating point notation representing the
amount of days from the defined epoch. In Delphi 3 I believe the epoch is
compatible with OLE which is 12/30/1899. If the value in question is a
DateTime the digits following the decimal point represent the time passed,
If Value is a Date the digits following the decimal point do not matter. So
to find the amount of days between two dates normal mathematical subtraction
can be applied.

Ross Bush

Quote
Henry Cheng wrote in message <378B3E9D.6A1EE...@hkstar.com>...
>1. I need compare two Date variable to find out how many days between
>two date.

>2. How to set the date (e.g.: Date + 7 days)

>Sorry for above question, it seems so easy but I cannot found in some
>manual, and I try many work also can't do it.

>Henry Cheng

Re:How to Compare/Change ** Date **


ElapsedDays := Trunc(Date1) - Trunc(Date2);

NextWeek := Date1 + 7;

Bill

--

Bill Todd - TeamB
(TeamB cannot respond to email questions. To contact me
 for any other reason remove nospam from my address.)

Other Threads