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!

datediff in report?

Status
Not open for further replies.

EgWeb

MIS
Oct 14, 2002
52
0
0
US
Hello,

I've got a report in which each record has a "startdate" and "completiondate". Can I calculate the number of weeks between these when running the report?

Thanks,
Andy
 
Andy,

Add an unbound text box with something like this as the control source:
Code:
=DateDiff("ww", [startdate], [completiondate])

Hoc nomen meum verum non est.
 
One step further...

Ok I set a control to this:
="Weeks: " & (DateDiff("ww",Now(),[LastContact])*-1)

Can I put a condition into place that if "LastContact" has no value that it would be blank?

Thanks!
Andy
 
If you mean that the whole control should be blank, it would be something like this:
Code:
=IIf ([LastContact] Is Null,"","Weeks: " & (DateDiff("ww",Now(),[LastContact])*-1))


Hoc nomen meum verum non est.
 
Cosmo, you're a genius...

Why the 2 I's on the IF though?

Thanks!
Andy
 
The IIF function is an immediate IF, it will return one of two values based on whether an expression is true or false. It has three arguments. The first argument is the expression to test, the second argument is the value to return if the expression is true, and the third argument is the value to return if the expression is false.

It's a slightly more compact method than using an
Code:
If Then Else....
statement....

Hoc nomen meum verum non est.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top