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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating difference between two dates 1

Status
Not open for further replies.

topgeek

MIS
Oct 28, 2001
59
0
0
GB
Hi There

I have two fields, DateStart and DateAgreed and need to display how many days overdue a project is in another textbox on the same form if DateAgreed is greater than DateStart.

Any ideas how I might acheive this?

Many thanks in advance.
 
In the 'Overdue' text box - make the Control Source

= Iif(DateAgreed > DateStart,DateAgreed - DateStart, "")





'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
topgeek,

To just add a tad to G L S's post, Dates are merely NUMBERS, like today is 38154. That's how Microsoft applications store dates. Dates can be FORMATTED to DISPLAY Year, Month, and Day, each in a number of numeric or text formats. So the gross difference in days is just a simple arithmetic difference of date values.

:)


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 


DateStart and DateAgreed


overdue=Datediff("d",[datestart],[dateagreed])

[Overdue] will equal the difference in days from field [datestart] and [dateagreed]

Kramerica
 
Thanks Little Smudge,

Should I now see a number displayed in the Overdue text box. Assumning the two dates are different of course!

I pasted your code staright into the Control Source


Thanks
 
As long as DateAgreed and DateStart both contain Date type data then Yes.

If either are null then you won't.


When you foinished typing click out to a different property and check that the i in 'Iif' capitalises automatically to I.
If it doesn't you've got a formatting error somewhere in your text.




'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top