Question

Locked

if then statement code

By dgearheart ·
I am trying to write a statemtn in access that will determine if a date is null and if it is respond with "0", if it is true, I want to be able to count the days (datediff) between it and a second date. If the second date is null, I would like to count the days from the first date to "today". I also have a re-start and re-end date that I would like to incorporate and count all days. I would love any feed back and direction possible.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

I am not sure I see the problem

by john.a.wills In reply to if then statement code

if isnull (me.date1) _
then
me.X = 0
else
if isnull (me.date2) _
then
me.X = datediff(me.date1,today, whatever)
else
me.X = datediff(me.date1,me.date2,..)
endif
endif

Collapse -

getting an error

by dgearheart In reply to I am not sure I see the p ...

John.a.wills,

Thank you for your help, however when I type in the following I get an error that states, "The expression you entered contains invalid syntax. You may have entered an operand without an operator." I think my problem is that I do not have the proper punctuation.

Rest days: if is null [Rest Duty Start Date]_ then Rest days=0 else if isnull [Rest Duty End Date] then Rest days= datediff([Rest Duty Start Date],today) else [Rest Duty Start Date],[Rest Duty End Date] end if

Please help, I am not sure the proper code with proper punctuation.

Thanks

Collapse -

help

by john.a.wills In reply to getting an error

is available on datediff - I cannot help there off-hand. More important, perhaps: you have "Rest days" as two separate words outside brackets.

Back to Software Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums