Agent flagging documents

I coded an agent to compare an ending date to the current date and flagging the doc as EXPIRED, with its runtime set to after documents are created or modified with the following code:

@If(To < @Today;@SetField(“Status”;“EXPIRED”);" ");

SELECT @All

but the agent is not flagging documents with past ending dates “EXPIRED”. Can someone give me some advice??

Subject: Agent flagging documents

Is the To field really a date field? Or just a text field that contains a date string? If it’s text, you’ll need to convert it in the formula so that you’re comparing apples with apples:

@If(@TextToTime(To) < @Today;@SetField(“Status”;“EXPIRED”);" "); SELECT @All

Also, what is the agent trigger and target?

Subject: RE: Agent flagging documents

The TO field is a date field selected from a dropdown calendar, trigger is on the event of a created or modified document.