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

Using DateAdd Function to Calculate Elapsed Time

Status
Not open for further replies.

Barbara265

Technical User
Oct 16, 2000
30
0
0
US
I am using Crystal 7 and have installed the UFL to enable use of the DateAdd function. (Thanks to Ken Hamady for pointing this out in his FAQs)

I want to determine if a 30, 60, or 90 day review is due based on the number of days that have elapsed since the recent hire date. I have tried the following:

If DateAdd('d',30,DateTime({EEmploy.EeDateLastHire})) <= 30 Then
'30 Day Review'

When I check for errors, Crystal tells me it is expecting a DateTime field where I have &quot;<= 30&quot;. I have tried not using the DateTime function to convert EEmploy.EeDateLastHire and Crystal balks at that too.

Clearly I'm not using the DateAdd function correctly and am looking for advice on what I need to do to make this work.

Thanks,
Barb
 
Hey Barbara,

The correct syntax for DateAdd is:

DateAdd(IntervalType - like Day or Month,Number of Intervals,Date)

Ideally, what you're aiming for is something like:
Code:
If DateAdd('d',30,{EEmploy.EeDateLastHire}) <= CurrentDate Then
   '30 Day Review'
or
Code:
If {EEmploy.EeDateLastHire} >= CurrentDate-30
Then
   '30 Day Review'
If {EEmploy.EeDateLastHire} is a Date field, which I've assumed in these examples that it is, you don't need to convert it to a DateTime for the DateAdd function.

All the best,

Naith
 
Barb,

I don't know if CR7 has the datediff function, if it does then I would use the following :

if DateDiff (&quot;d&quot;,date {EEmploy.EeDateLastHire}),currentdate) = 30 then &quot;30 Day Review)

Juan
Scotland (currently)
 
Thanks to both Juan and Naith... I'm just about there now and I appreciate your assistance.

Barb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top