Quick Question on FTSearch

For the life of me I cannot find out how to properly format a query for a FTSearch. I Can’t find info either in on the IBM biblio site…

I’m writing a agent that will create a folder named %lastyear% and put all documents in the inbox into that folder.

It will run only on Feburary First…

What I have is:

'Dim stuff already done…

Call thisDate.Adjustyear( -1 )

yearString = Strrightback( thisDate.Dateonly, “/”)

query = |Field ‘Created’ =| & yearstring

Set db = s.Currentdatabase

Set dc = db.Ftsearch( query, 0, FT_DATE_ASC )

Call db.Enablefolder( yearString )

While Not (doc Is Nothing)

Call doc.putinFolder ( yearString, False)

Set doc = dc.Getnextdocument( doc )

Wend

The query doesn’t look right…

I’m trying to get the document created Year in the document collection but I just can’t figure the syntax…

Can anyone help?

Thank you…

Subject: Try a “> & <” operation…

This worked for me from Notes:

“[_CreationDate] > 01/01/2008 & [_CreationDate] < 01/01/2009”

I know that I have documents created on 10/15/2008, so I tried “[_CreationDate] CONTAINS 10/15/2008” and it fails with the same error you’re getting. (It could be that CONTAINS fails since _CreationDate is a date/time and the operation is doing a string comparison. Maybe internally it won’t cast to a string. Not sure about that.)

Hope this helps,

Scott

Subject: I just tried both suggestions… Still error

yearString is 2010 in this case…

query = |[_CreationDate] => 01/01/|& yearString &| & [_CreationDate] <= 12/31/|& yearstring

Set db = s.Currentdatabase

Set dc = db.Ftsearch( query, 0, FT_DATE_ASC )

…and I still get “Query is not Understandable”.

This is a mail 8.5.1 Mail DB which is being used for a mail-in account…

It seems like there is no way to get the actual “Memo” forms creation date…

Subject: => is not a recognized comparison operator.

When you have a problem with a query, it’s usually helpful to try the query manually in a view. And if it fails, try different parts of it until you narrow down the problem.

Subject: Remove the ’

Should be

Field created = …

alternatively you can do .

[created] = …

Although the format of the created field is important. The above would only really work if it was single year number or text field.

If it was a date field then I would do something like.

[created] >= 01/01/2010 AND [created] <= 31/12/2010

Subject: for example…

right from the help file…

Field name special cases

Use the fieldname _CreationDate to find documents by the date they were created. For example,

[_CreationDate]=1/05/2001

finds documents created on January 5, 2001.

and if I use it for what I need:

query = [_CreationDate] CONTAINS 2010

I get a query not understandable…

Subject: Got it

There is no special…[_CreationDate] function. I have to idea what the hell Notes help is tallking about…

But I used:

query = |Field $Created >= 01/01/| & yearString & | AND Field $Created <= 12/31/|& yearstring

and this created the correct results.

Thanks to all!!

Subject: [_CreationDate] is perfectly valid and the Notes help is correct.

I should know, I wrote that bit myself. Read all the responses in your thread; I said what the problem was.

Subject: Oh I understand the responses…

but when I try to use the [_creationDate] in the query is always comes back with “query not understandable”… but if I change it to $Created… it works… And thanks to you…i did noticed the operator error…

Thanks Andre!

(I know this would be your 3rd post…)

Subject: $Created is not a standard fieldname, and [_CreationDate] does work

Try this search in this database: [$Created] > 8/31/2010

Now try: [_CreationDate] > 8/31/2010

Which one works? You were getting “Query not understandable” because you had syntax errors in your query – but the syntax error wasn’t from using _CreationDate. The help is accurate on this one. I have used this again and again, and it never fails.

And, documents rarely contain a $Created item, and it’s not necessarily the same as the document creation date if it does exist. So even if _CreationDate didn’t work, $Created isn’t a general solution.