Another if statement problem

twychopen22

Registered User.
Local time
Today, 15:13
Joined
Jul 31, 2006
Messages
101
I just need to know how to compare 2 dates in an if statement:
IIF (LastActivation) >= (Date()), (DueToday)= "Yes", (DueToday) = "No"
 
DueToday: IIF ([LastActivation]>=Date(),"Yes","No")
 
FoFa said:
DueToday: IIF ([LastActivation]>=Date(),"Yes","No")

Thanks, but when I run it it says Data type mismatch in criteria expression...
Ok, figured it out, The "DueToday" field is yes/no not text...How do I fix this problem (I know how to change it from text to y/n but will that affect my following queries?

I have changed things around and it will not execute correctly anyway. I made an expense due but it did not show up as Yes

I tried changing > to < so that if today is larger than the last activation it would be "yes" (due again) but then nothing at all shows
 
Last edited:
Yes is stored as -1 and No as 0, so you can use
Code:
DueToday: IIF ([LastActivation]>=Date(),-1,0)
 
Hi -

[LastActivation]>Date() doesn't seem very logical. Perhaps [LastActivation]<Date()...?

Bob
 
raskew said:
Hi -

[LastActivation]>Date() doesn't seem very logical. Perhaps [LastActivation]<Date()...?

Bob

That is true, and now at least with the -1,0 it runs. Depending on the < > direction it either shows my 6 records, or none at all. I think it is running correctly but it is not updating the yes no correctly.
 
raskew said:
Hi -

[LastActivation]>Date() doesn't seem very logical. Perhaps [LastActivation]<Date()...?

Bob

Depends on meaning of LastActivation. If it means the date on which it was last activated, you are correct. If, however, it means the last date on which it may or must be activated, it makes perfect sense.


twychopen22 said:
That is true, and now at least with the -1,0 it runs. Depending on the < > direction it either shows my 6 records, or none at all. I think it is running correctly but it is not updating the yes no correctly.
Bob

What's it doing with the "yes"/"no"?
 
Last edited:
yes it has been updated (off the update query) or no it has not been updated
 
I'm sorry. I look at my last question and see it's very vague.

You say it's not updating yes no correctly. What are you getting with the six records? What is the value of LastActivation and what is the output of the IIf statement?
 
grnzbra said:
I'm sorry. I look at my last question and see it's very vague.

You say it's not updating yes no correctly. What are you getting with the six records? What is the value of LastActivation and what is the output of the IIf statement?

If the expense is due again, then it should say yes. I can't get it to say yes. the six records are the only records I have (just trial records) and I run the query and if it is supposed to be yes they show up, if no they don't show up, that is sorta what I want but with the criteria yes/no checked or unchecked accordingly.

LastActivation is the last time the expenses were updated. I don't know what you mean "output of iif statement".
My database is under the general forum with a similar question I asked a long time ago if u want to look at it. The queries are query1 and 3
 
Last edited:
twychopen22 said:
LastActivation is the last time the expenses were updated. I don't know what you mean "output of iif statement".

The input is the date and the output is either 0 or -1 (which you said allows it to work) If the conditional portion of the IIf statement is true, do you get a -1 and if it is false, do you get a 0 (or vice versa, depending on how you set it up)?

If you put a criteria into the field, either 0 or -1, you should be able to control which records show up.
 

Users who are viewing this thread

Back
Top Bottom