Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with DateDiff function

Status
Not open for further replies.

Tailgun

Technical User
Mar 30, 2002
417
US
I have a form with 3 textboxes and need some code help with the DateDiff function.

txtOpenDate this has a DataFormat of Date mm/dd/yyyy
txtClosedDate this has a DataFormat of Date mm/dd/yyyy

The third text box has a DataFormat of Number

I need to know the diff in days between ClosedDate from OpenDate and display the difference in days in the third txtbox.

Any help would be greatly appreciated.

 
You might try something like the following, assuming that both txtOpenDate and txtClosed Date contain valid dates

NumDays = Abs(DateDiff("d", txtOpenDate.Text, txtClosedDate.Text))

txtNumDays.Text = Trim(NumDays)

The use of the Absolute Value function will always return a positive number, otherwise, DateDiff may return a negative number, depending on the order the two dates are used. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Text3.Text = DateDiff("d", Text1.Text, Text2.Text) Swi
 
Thanks Cajun and SWI :):)

It works great !!

and thanks for the fast response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top