How do I Compair Table date to current date

ramasule

Registered User.
Local time
Today, 15:30
Joined
Mar 13, 2007
Messages
33
Hello,

I was wondering how to check a date in a table vs current date and
then put a yes/no in a colum if the date in the table is past current date.

In the form I know it should be wrote in the Upon Open Event
But I am unsure of the code.

Thank you for your time,

Derek L
 
This is actually an UPDATE query situation, unless you really, REALLY, REALLY wanted it in form code.

Just do an update to the YES/NO column if the stored date is > Now() (for true Date fields) or CDate([stored date]) > Now() (for text-form dates).

You would put the indicated expression as the update value for the Yes/No field and you could use the Expression Builder to help you build that.
 
Ok so I have
=IIf(Projects![Date Expired]>=Now(),-1,0)
Where do I put this?

I tried putting it in the before update, then the after update niether worked.

Also is it easy to do a ( Now() - #00/01/00# ) to let me know when
it is about to expire.
 
IIF is not what you want.

In the Update query grid, there is a place where you put the value that you want to stuff into the field.

Put an expression such as ( [tabledate] < Now() ) with a relational operator between the date fields. The relational operator yields a value of TRUE or FALSE (Yes or No). Store the result of that expression into the Yes/No field and suddenly you have something you can use in subsequent queries.

You can do such a thing as a DateDiff() - a function taking the difference between two dates and giving back the answer in selected units. "About to expire" is a relative and highly subjective term. If you can define the criteria you want to apply in a particular set of units, I'd bet that DateDiff is the way to do at least part of that computation.
 
Ok so I have
=IIf(Projects![Date Expired]>=Now(),-1,0)
Where do I put this?

I tried putting it in the before update, then the after update niether worked.

Also is it easy to do a ( Now() - #00/01/00# ) to let me know when
it is about to expire.

WHERE (Date Expired-1)=Date()

Will match the date one day before it is due to expire when using a query.
 

Users who are viewing this thread

Back
Top Bottom