Date Calculations

  • Thread starter Thread starter David Urquhart
  • Start date Start date
D

David Urquhart

Can anyone please help,
I have a table and a form with a start date and I want
both of them to show either a date 200 days hence or that
the item has passed this date & how many days to this date
many thanks
david
 
Dates are really stored as numbers. The whole number part being the number
of days since the turn of the century (well actually since the 30 Dec1899).
Consequently you can just add 200 to get your future date.

I don't think you'd need to store the future date in your table, just
calculate it and show it on the form in a textbox. In regard to indicating
if the future date has passed, I'd suggest altering the colour of the text
to red.

So how to do this....
Create your form with the StartDate in the forms underlying query. (where
StartDate is your field name)
Add a new textbox and set its Control Source to =StartDate+200
With the focus on the new textbox, open the format menu and choose
conditional formatting.
Create Condition 1 as "Field value is greater than Now()" and change the
forecolor to Red.

HTH
Sam
 
David said:
Can anyone please help,
I have a table and a form with a start date and I want
both of them to show either a date 200 days hence or that
the item has passed this date & how many days to this date
many thanks
david


There are two things here:

1. You want to calculate and display a date that is 200 days ahead of
some stored date.

2. You want to indicate that some stored date is 200 and more days old
compared to today's date.

You can do both of these these things in a Form's underlying Query
and/or in Functions which you call from the Query and/or from your
Form. What is certain is that in neither case do you need to store any
of these calculated values, nor should you!

For the calculations themselves, have a look in Help for 1. DateAdd()
and 2. DateDiff().

hth

Hugh
 
Can anyone please help,
I have a table and a form with a start date and I want
both of them to show either a date 200 days hence or that
the item has passed this date & how many days to this date
many thanks
david

I'm not quite clear what you're asking: do you want to show the date
200 days hence? This can be easily done using a Textbox with a control
source

=DateAdd("d", 200, [StartDate])

If you want a textbox to show OVERDUE in big red letters, you can use
a Control Source

=IIF(Date() > DateAdd("d", 200, [StartDate]), "OVERDUE", "")

with appropriate font and color.
 
Back
Top