lotus notes search by date with Java api












3















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?










share|improve this question



























    3















    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?










    share|improve this question

























      3












      3








      3


      1






      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?










      share|improve this question














      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?







      java date lotus-notes






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 1 '12 at 0:49









      grooblegrooble

      3681420




      3681420
























          2 Answers
          2






          active

          oldest

          votes


















          4














          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.






          share|improve this answer


























          • It worked. After everything I tried... square brackets. Keep it simple, I suppose... Thanks a lot.

            – grooble
            Jun 1 '12 at 1:35











          • Woops, I just checked what was in the returned DocumentCollection and it's null. I happen to know that there are lots of records that meet this date criteria. Could it be because "Date" is not a text field but type 1024: date-time or range of date-times?

            – grooble
            Jun 1 '12 at 8:02






          • 1





            On second look of this, I think I had it wrong - the brackets are appropriate for the date constant, just not the Date field variable. I've updated the answer. I believe my original suggestion compared Date to the calculation of 3 divided by 20 divided by 2012 :)

            – Ken Pespisa
            Jun 1 '12 at 13:05








          • 2





            @grooble, I would try working out the kinks of the search formula by creating a view and experimenting with the formula right in the view designer. You can get instant feedback that way.

            – Ken Pespisa
            Jun 1 '12 at 13:10



















          3














          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".






          share|improve this answer



















          • 1





            See problems above. And, yep, the line you provided above worked with FTSearch and gave me records. Thanks to both of you! You're on my list of vote-ups for when I hit 15 rep. ;)

            – grooble
            Jun 1 '12 at 8:09












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10843113%2flotus-notes-search-by-date-with-java-api%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          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.






          share|improve this answer


























          • It worked. After everything I tried... square brackets. Keep it simple, I suppose... Thanks a lot.

            – grooble
            Jun 1 '12 at 1:35











          • Woops, I just checked what was in the returned DocumentCollection and it's null. I happen to know that there are lots of records that meet this date criteria. Could it be because "Date" is not a text field but type 1024: date-time or range of date-times?

            – grooble
            Jun 1 '12 at 8:02






          • 1





            On second look of this, I think I had it wrong - the brackets are appropriate for the date constant, just not the Date field variable. I've updated the answer. I believe my original suggestion compared Date to the calculation of 3 divided by 20 divided by 2012 :)

            – Ken Pespisa
            Jun 1 '12 at 13:05








          • 2





            @grooble, I would try working out the kinks of the search formula by creating a view and experimenting with the formula right in the view designer. You can get instant feedback that way.

            – Ken Pespisa
            Jun 1 '12 at 13:10
















          4














          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.






          share|improve this answer


























          • It worked. After everything I tried... square brackets. Keep it simple, I suppose... Thanks a lot.

            – grooble
            Jun 1 '12 at 1:35











          • Woops, I just checked what was in the returned DocumentCollection and it's null. I happen to know that there are lots of records that meet this date criteria. Could it be because "Date" is not a text field but type 1024: date-time or range of date-times?

            – grooble
            Jun 1 '12 at 8:02






          • 1





            On second look of this, I think I had it wrong - the brackets are appropriate for the date constant, just not the Date field variable. I've updated the answer. I believe my original suggestion compared Date to the calculation of 3 divided by 20 divided by 2012 :)

            – Ken Pespisa
            Jun 1 '12 at 13:05








          • 2





            @grooble, I would try working out the kinks of the search formula by creating a view and experimenting with the formula right in the view designer. You can get instant feedback that way.

            – Ken Pespisa
            Jun 1 '12 at 13:10














          4












          4








          4







          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.






          share|improve this answer















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 1 '12 at 13:06

























          answered Jun 1 '12 at 1:32









          Ken PespisaKen Pespisa

          19.4k34760




          19.4k34760













          • It worked. After everything I tried... square brackets. Keep it simple, I suppose... Thanks a lot.

            – grooble
            Jun 1 '12 at 1:35











          • Woops, I just checked what was in the returned DocumentCollection and it's null. I happen to know that there are lots of records that meet this date criteria. Could it be because "Date" is not a text field but type 1024: date-time or range of date-times?

            – grooble
            Jun 1 '12 at 8:02






          • 1





            On second look of this, I think I had it wrong - the brackets are appropriate for the date constant, just not the Date field variable. I've updated the answer. I believe my original suggestion compared Date to the calculation of 3 divided by 20 divided by 2012 :)

            – Ken Pespisa
            Jun 1 '12 at 13:05








          • 2





            @grooble, I would try working out the kinks of the search formula by creating a view and experimenting with the formula right in the view designer. You can get instant feedback that way.

            – Ken Pespisa
            Jun 1 '12 at 13:10



















          • It worked. After everything I tried... square brackets. Keep it simple, I suppose... Thanks a lot.

            – grooble
            Jun 1 '12 at 1:35











          • Woops, I just checked what was in the returned DocumentCollection and it's null. I happen to know that there are lots of records that meet this date criteria. Could it be because "Date" is not a text field but type 1024: date-time or range of date-times?

            – grooble
            Jun 1 '12 at 8:02






          • 1





            On second look of this, I think I had it wrong - the brackets are appropriate for the date constant, just not the Date field variable. I've updated the answer. I believe my original suggestion compared Date to the calculation of 3 divided by 20 divided by 2012 :)

            – Ken Pespisa
            Jun 1 '12 at 13:05








          • 2





            @grooble, I would try working out the kinks of the search formula by creating a view and experimenting with the formula right in the view designer. You can get instant feedback that way.

            – Ken Pespisa
            Jun 1 '12 at 13:10

















          It worked. After everything I tried... square brackets. Keep it simple, I suppose... Thanks a lot.

          – grooble
          Jun 1 '12 at 1:35





          It worked. After everything I tried... square brackets. Keep it simple, I suppose... Thanks a lot.

          – grooble
          Jun 1 '12 at 1:35













          Woops, I just checked what was in the returned DocumentCollection and it's null. I happen to know that there are lots of records that meet this date criteria. Could it be because "Date" is not a text field but type 1024: date-time or range of date-times?

          – grooble
          Jun 1 '12 at 8:02





          Woops, I just checked what was in the returned DocumentCollection and it's null. I happen to know that there are lots of records that meet this date criteria. Could it be because "Date" is not a text field but type 1024: date-time or range of date-times?

          – grooble
          Jun 1 '12 at 8:02




          1




          1





          On second look of this, I think I had it wrong - the brackets are appropriate for the date constant, just not the Date field variable. I've updated the answer. I believe my original suggestion compared Date to the calculation of 3 divided by 20 divided by 2012 :)

          – Ken Pespisa
          Jun 1 '12 at 13:05







          On second look of this, I think I had it wrong - the brackets are appropriate for the date constant, just not the Date field variable. I've updated the answer. I believe my original suggestion compared Date to the calculation of 3 divided by 20 divided by 2012 :)

          – Ken Pespisa
          Jun 1 '12 at 13:05






          2




          2





          @grooble, I would try working out the kinks of the search formula by creating a view and experimenting with the formula right in the view designer. You can get instant feedback that way.

          – Ken Pespisa
          Jun 1 '12 at 13:10





          @grooble, I would try working out the kinks of the search formula by creating a view and experimenting with the formula right in the view designer. You can get instant feedback that way.

          – Ken Pespisa
          Jun 1 '12 at 13:10













          3














          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".






          share|improve this answer



















          • 1





            See problems above. And, yep, the line you provided above worked with FTSearch and gave me records. Thanks to both of you! You're on my list of vote-ups for when I hit 15 rep. ;)

            – grooble
            Jun 1 '12 at 8:09
















          3














          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".






          share|improve this answer



















          • 1





            See problems above. And, yep, the line you provided above worked with FTSearch and gave me records. Thanks to both of you! You're on my list of vote-ups for when I hit 15 rep. ;)

            – grooble
            Jun 1 '12 at 8:09














          3












          3








          3







          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".






          share|improve this answer













          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".







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 1 '12 at 2:31









          Richard SchwartzRichard Schwartz

          12.2k21636




          12.2k21636








          • 1





            See problems above. And, yep, the line you provided above worked with FTSearch and gave me records. Thanks to both of you! You're on my list of vote-ups for when I hit 15 rep. ;)

            – grooble
            Jun 1 '12 at 8:09














          • 1





            See problems above. And, yep, the line you provided above worked with FTSearch and gave me records. Thanks to both of you! You're on my list of vote-ups for when I hit 15 rep. ;)

            – grooble
            Jun 1 '12 at 8:09








          1




          1





          See problems above. And, yep, the line you provided above worked with FTSearch and gave me records. Thanks to both of you! You're on my list of vote-ups for when I hit 15 rep. ;)

          – grooble
          Jun 1 '12 at 8:09





          See problems above. And, yep, the line you provided above worked with FTSearch and gave me records. Thanks to both of you! You're on my list of vote-ups for when I hit 15 rep. ;)

          – grooble
          Jun 1 '12 at 8:09


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10843113%2flotus-notes-search-by-date-with-java-api%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues