Board index » delphi » HELP!!! I'm a novice who's going nuts...

HELP!!! I'm a novice who's going nuts...

Can anyone help me? I run a non-profit organization treating
dually-diagnosed {*word*62}s (mental health and {*word*60}ion). I'm trying to
write a small program to track clients and can't seem to do a simple
calculation based on two date fields.

I have a date field called IntakeDate and a date field called
DischargeDate. I want to subtract the DischargeDate from the IntakeDate
and put the results in another field called DaysIn (I have this field as
an integer) Seems like it would be simple but.....

I also want to calculate a new date from the discharge date  i.e. 180
days from the value in the DischargeDate field. The result placed in a
field called FollowUpDate1.

Any help would be greatly appreciated If you want, you can answer me
here or email me at n...@sagri.org

 

Re:HELP!!! I'm a novice who's going nuts...


On Fri, 29 Oct 1999 12:22:13 -0700, "Nicholas A. Jaros" <sa...@sagri.org>
wrote:

Quote
>Can anyone help me? I run a non-profit organization treating
>dually-diagnosed {*word*62}s (mental health and {*word*60}ion). I'm trying to
>write a small program to track clients and can't seem to do a simple
>calculation based on two date fields.

>I have a date field called IntakeDate and a date field called
>DischargeDate. I want to subtract the DischargeDate from the IntakeDate
>and put the results in another field called DaysIn (I have this field as
>an integer) Seems like it would be simple but.....

In Delphi, simply subtract one TDate or TDateTime value from another. The
result is a number representing the difference between the two values,
expressed in days.

  Table1.Fields[3].AsDateTime :=
    Table1.FieldByName('IntakeDate').AsDateTime -
    Table1.FieldByName('DischargeDate').AsDateTime;

Quote
>I also want to calculate a new date from the discharge date  i.e. 180
>days from the value in the DischargeDate field. The result placed in a
>field called FollowUpDate1.

Similarly, if you add a positive number to a TDate or TDateTime value, the
result is a date that many days after the original date.

  Table1.Fields[4].AsDateTime :=
    Table1.FieldByName('DischargeDate').AsDateTime + 180;

==========================================================================
Steve Koterski                  "Computers are useless. They can only give
Technical Publications          you answers."
Borland                                       -- Pablo Picasso (1881-1973)
http://www.borland.com/techpubs/delphi

Other Threads