lotus notes search by date with Java api

落爺英雄遲暮 提交于 2019-12-07 16:02:06

问题


I'm trying to select records by date from a Lotus Notes database and have run into trouble with correctly formatting the date.

Here's the relevant code:

public void runNotes()  {
    Session s;
    try {
        s = NotesFactory.createSession((String)null, (String)null, "mypassword");
        Database hkDB = 
            s.getDatabase("NBHDH001/YNM", "H\\DHH00001.nsf", false);
        DocumentCollection docs = hkDB.search("[Date]>[2012/03/20]");

Date is a field in the record, and when I looked up records (with FTSearch), the date came back in the format above: [yyyy/mm/dd].

The parameter of the search is what I need here. i.e. what should I put instead of "[Date]>[2012/03/20]"

I tried various constructions with Calendar and DateFormat, but it's not coming together...

Any suggestions?


回答1:


You should get rid of the square brackets on the field name. The search method expects a Notes Formula, like what you'd put into a view selection formula:

"Date > [03/20/2012]"

It might also be required that dates are in mm/dd/yyyy format, though if you are in a non-US locale I'm not 100% sure.




回答2:


You mentioned that you have been doing full text searches in the database, so it is definitely worth mentioning this... If the database actually has a full text index, then you may want to consider using the NotesDatabase.FTSearch() method instead of NotesDatabase.Search(). The FTSearch method will be considerably faster for a large database.

The syntax for FTSearch is different from the syntax for Search. You could use either "FIELD Date > 03/20/2012" or "[Date] > 03/20/2012".



来源:https://stackoverflow.com/questions/10843113/lotus-notes-search-by-date-with-java-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!