pdvsa
asked on
IIF and years/days
Experts, I have the following that returns the # of days but I need to include years. Also, if the txtContractBeginDate is Null or "" i woudl like the field to be blank but it still appends "days".
=IIf([txtContractBeginDate ]="","",(( [txtContra ctEndDate] -[txtContr actBeginDa te]) & " days"))
I would like it to be like so (if terms was 100 days):
0 years and 100 days
thanks
=IIf([txtContractBeginDate
I would like it to be like so (if terms was 100 days):
0 years and 100 days
thanks
how can you have an end date without a begin date?
any way you may want to do this with datediff. something like this to find days
daysofcontracts: IIf(DateDiff("d",[Contract BeginDate] ,[Contract EndDate])< 365,DateDi ff("d",[Co ntractBegi nDate],[Co ntractEndD ate]) & " Days","")
and anything over 365 meaning more than a year it would be this
Yearssofcontracts: IIf(DateDiff("d",[Contract BeginDate] ,[Contract EndDate])> 365,DateDi ff("yyyy", [ContractB eginDate], [ContractE ndDate])," ")
Play with these to get the years if there are any and the days
daysofcontracts: IIf(DateDiff("d",[Contract
and anything over 365 meaning more than a year it would be this
Yearssofcontracts: IIf(DateDiff("d",[Contract
Play with these to get the years if there are any and the days
to check for null you would do so like nz([contractBeginDate],0)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gustav: thanks.... one question: do I make a module for the function? I am not too familiar with modules. I get a #Name after copy and paste of the IIF and dont know if this is because I have not used the function.
Yes.
Open a new module, copy and paste the function, then compile the module and save as, say, basDateUtils.
/gustav
Open a new module, copy and paste the function, then compile the module and save as, say, basDateUtils.
/gustav
ASKER
whoa that was cool. Dont understand how it works but it works!
thank you for the expert help.
thank you for the expert help.
Great!
It is VBA, Visual Basic for Applications.
/gustav
It is VBA, Visual Basic for Applications.
/gustav