You are viewing limited content. For full access, please sign in.

Question

Question

Unable to query by Date Modified within 2 hours

asked on April 20, 2015 Show version history

In a workflow, I was able to successfully query documents in a folder, containing more than one file, and modified in the last day as follows:

{LF:Name="*", Type="DB"} & {LF:Modified>%(DateTokenCalculator_Date - 1 Day)} & {LF:LOOKIN="<REPOSITORY NAME>\%(ForEachFolder_CurrentEntry_FullPath)"}

The Date - 1 Day date token was calculated by taking a Custom Date and subtracting 1 day. 

However, I want to do a search for documents modified in the last couple of hours.  I tried creating a date token for this by taking a Custom Date and Time and subtracting two hours (as well as just Custom Time), but when I run this query instead, I'm presented with the following:

 

  2015-04-20 9:42:15 PM Search For Recent files A syntax error was encountered while processing the search or query statement. [9084]

 

Can anyone think of any reason why my query would work with a custom token subtracting one day, versus a custom token subtracting a couple of hours?  

Thanks to anyone who can help!

Marty Gaffney - Network Technician

Town of Okotoks

0 0

Answer

SELECTED ANSWER
replied on April 22, 2015

Oh, can't believe i didn't see it before. Can you add double quotes around the token so the date value is surrounded by them when the query runs? It should end up being {LF:Modified>"2015-04-21"}, not {LF:Modified>2015-04-21}.

1 0

Replies

replied on April 21, 2015

Do you have the values of the date token for the 2 cases?

0 0
replied on April 21, 2015

Thanks for the reminder, I completely forgot to check these first!  Nonetheless, here are the token values in my results:

datetokencalculator_date - 1 day: 20/04/2015

datetokencalculator_date - 6 hours: 21/04/2015 2:34:00 AM (tried 6 last night for testing)

Also:

startime dateetime 21/04/2015 8:34:08 AM

lastmodifieddate 20/04/2015 10:15:51 AM (this is the variable I'm using for comparison)

Thanks for your assistance with this!

0 0
replied on April 21, 2015

They do look ok. I'm not seeing something obviously wrong with the dates. The only thing that stands out is that the date in your message is formatted as yyyy-MM-dd, while the ones in your examples are a dd/MM/yyyy.

What is the date/time format on the Laserfiche server?

0 0
replied on April 21, 2015

Our default date format is yyyy-MM-dd, and our default time format is h:mm tt.  I noticed the default date and time format was different on the server that hosts Workflow, however changing the date and time format there to match our main Laserfiche server didn't appear to fix this error.

Could this possibly be tied to the date and time format of the machine where the document was created/modified?

0 0
replied on April 21, 2015

No, the modified date is saved in the server in an invariant format and then processed by the clients into the local format.

To make it slightly more complicated, the date format you see may not be the same one the servers use since they'd use the date format for the Windows accounts their corresponding services are running under

Could you try formatting the token in the search query to the yyyy-MM-dd format?

If Audit Trail is available to you, could you look up the search event and see what the search query was exactly?

0 0
replied on April 21, 2015

Sure - I'll give that a try shortly here and get back to you.

0 0
replied on April 21, 2015

Okay, here's what I've found to this point:

1) I tried formatting the date token in the search query both as #"yyyy-MM-dd"# and #"yyyy-MM-dd hh:mm:ss"#, and in either instance I got a different error message, saying "An unrecognized character was encountered."

2) After enabling auditing for the search function on this repository, I was able to get the exact queries that were run:

Without formatted token:

{LF:Name="*", Type="DB"} & {LF:Modified>21/04/2015 9:45:00 AM} & {LF:LOOKIN="<folder name>"}

With formatted token (formatted both for date, as well as date/time):

{LF:Name="*", Type="DB"} & {LF:Modified>2015-04-21} & {LF:LOOKIN="<folder name>"}

{LF:Name="*", Type="DB"} & {LF:Modified>2015-04-21 04:37:00} & {LF:LOOKIN="<folder name>"}

Thanks again.

0 0
SELECTED ANSWER
replied on April 22, 2015

Oh, can't believe i didn't see it before. Can you add double quotes around the token so the date value is surrounded by them when the query runs? It should end up being {LF:Modified>"2015-04-21"}, not {LF:Modified>2015-04-21}.

1 0
replied on April 24, 2015

Yep, that did it!  I hadn't used quotes to this point, because I was referencing a date-based token, but once I changed my query to the following, no more errors:

{LF:Name="*", Type="DB"} & {LF:Modified>"%(Modified Date)"} & {LF:LOOKIN="<repositoryname>\%(ForEachFolder_CurrentEntry_FullPath)"}

I also went back and tried this with my original date token, and this worked as well.  Thanks for looking into this - this will definitely come in handy moving forward!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.