calculate number of days between two dates

playagain

Registered User.
Local time
Today, 21:55
Joined
Oct 4, 2007
Messages
14
Hi...

I have two forms with two textboxes:
The first textbox asks for the beginning date while the second textbox asks for the end date.
These two textboxes are formatted and masked as "short date".
Then I created a third textbox that must automatically display the number of days between the two dates.

Please help me how to do it..

P.S. This form is connected to a table and the rowsources are: d_dgranted and d_dmaturity

please help me thanks a lot
 
You should be able to do this with the datediff() function...


:)
ken
 
How to do this...??? will i type this in the third textbox???
 
In the third text box's control source put something like:

=datediff(me!dateboxname1,me!dateboxname2)

:)
ken
 
yes thanks to all of you... I typed this in a third textbox:

=DateDiff("d",[d_dgranted],[d_dmaturity])

It worked...

But my other problem is how can i connect this now into my table ???
 
You can basically do the same thing in a query of the table. This is a calculated field and should not be stored in a table. You can use the query builder to help you develop the query.
 
I typed this in the third box:

= Datediff("d", [d_dgranted], [d_dmaturity])

and it computed the difference of the two dates in two textboxes..

The two textboxes are connected in a table... and I want also the third box to be connected on that table..

But how can I do this since I typed the code of the control source of the third textbox???

Please help me
 
What is wrong with putting:
NewField:=Datediff("d", [d_dgranted], [d_dmaturity])
...in the Field name of a query of that table and then binding that new field to the 3rd TextBox?
 
i have only table and a form connected to it... I don't have a query on that table... Pls help me :)
 
Forms can not tell the difference between tables and queries as their RecordSource but queries are far more powerful. Use the Query Builder Wizard to create a query of the table you are using that includes all of the fields. Switch to DataSheet view in the query and see if you have all of the records. Post back when you are done or need additional asistance.
 
I have done making a query of that table and put the formulas/expressions on some fields... my problem is how can i put the calculated values from query to my form and connected it again to my table???
 
Change the RecordSource of your form to point to the query you made and then change the ControlSource of the calculated control to point to the calculated field you made.
 
That's what I did... and it all worked... :) so can I delete now the table and use the query instead.?
 
NO! PLEASE! A query is simply a controlled window into a table. The table is the object that holds the data. A query will not work without the table it references.
 
thanks... I did'nt delete the table.. but now,,,, the calculated fields in the form automatically reflects in my query but not in my table... is it normal???
 
thanks... I did'nt delete the table.. but now,,,, the calculated fields in the form automatically reflects in my query but not in my table... is it normal???
Yes. Remember, this field is not needed in your table since you can calculate it any time you want with a query. Glad you did not delete the table.
 
so can I use the query to create reports instead of the table since the my query holds the complete details of my form?

THANKS AGAIN...

May GOD BLESS YOU and your FAMILY
 
so can I use the query to create reports instead of the table since the my query holds the complete details of my form?
Absolutely! Forms and Reports can not tell the difference between a table and a query but queries are far more powerful. All of my forms and reports run from queries. I only use a table when I'm doing a quick and dirty test for something.
 

Users who are viewing this thread

Back
Top Bottom