Searching using Time Values

Does anybody know how to do a FTSeach or a db.Search using time values only? I’ve tried and can’t get anything to work. I can’t find anything on the forums that say you can or can’t do this. Anybody know? Please help.

  • jamie

Subject: Searching using Time Values…

What have you tried? I always test out in the search bar first to get the syntax correct.

Subject: RE: Searching using Time Values…

I can’t get anything to work as far as time is concerned. I have a field named Date_Created that is computed when composed that contains the creation date and time. I want all documents created from noon until 3:00pm.

FIELD @TIME( DATE_CREATED ) > 12:00:00 P.M. doesn’t work

FIELD DATE_CREATED > 12:00:00 P.M. doesn’t work

So I build another computed field named TIME_CREATED that only displays time and its value is @Time(Date_Created).

FIELD TIME_CREATED > 12:00:00 PM

FIELD @TIME( TIME_CREATED ) > 12:00:00 PM

ANY IDEAS?

Subject: RE: Searching using Time Values…

Have you tried literalizing your time value:

[12:00:00PM]

Subject: RE: Searching using Time Values…

No, can you give me a bit more of an example - I’ll try it. Thank you!

Subject: RE: Searching using Time Values…

Stan is correct. To compare a date time value to a literal time value you have to enclose it in square brackets (this is in the Help).

@If(@Time(@Created) > [12:00:00 PM] ;

 @Prompt([OK] ; "Yes" ; "Created after 12PM" ) ;

 @Prompt([OK] ; "No" ; "Created before 12PM" )

)

Subject: RE: Searching using Time Values…

But since you’re using LotusScript you can easily form the date/time values to use in your search dynamically.

For example:

Const FORM_NAME = “Response”

Const DATE_FORMAT = “mm/dd/yyyy”

Dim nsess As NotesSession

Dim ndbSrc As NotesDatabase

Dim dclxn As NotesDocumentCollection

Dim strDateVal As String

Dim strSrchVal As String

Set nsess = New NotesSession

Set ndbSrc = nsess.CurrentDatabase

strDateVal$ = “[” & Format(Today, DATE_FORMAT) & “]”

strSrchVal$ = {Form = “} & FORM_NAME & {” & @Created >= } & strDateVal$

Set dclxn = ndbSrc.Search(strSrchVal$, Nothing, 0)

Msgbox “The search returned " & dclxn.Count & " document(s).”, , “Results . . .”

hth,

dgg

Subject: RE: Searching using Time Values…

Just one thing here – I’d recommend using one of the named formats rather than a declarative formatting string, since the [time goes here] formula value will be interpreted according to system settings. Since the named formats return strings according to system settings too, you’re much less likely to run into conversion problems.

Subject: RE: Searching using Time Values…

OK, I see your point about the conversion problems, but I’m not exactly sure which format you are telling me to use.

I started using the below in my code and it works great. Simple solution, but I just didn’t know it. Thanks for everyone’s help! I really appreciate it.

’ Start Date

If Not StartDate Is Nothing Then

strQuery$ = strQuery$ + " & ( @Date(DATE_CREATED) >= [" + StartDate.DateOnly + “] )”

End If

’ Start Time

If Not startTime Is Nothing Then

		strQuery$ = strQuery$ + " & ( @Time(DATE_CREATED) >= [" + StartTime.TimeOnly + "]  )"

End If

Subject: RE: Searching using Time Values…

Using the NotesDateTime object, you are already getting system-setting conversions. Had you been using date-time variants, the only change needed would be to redo these lines:

strQuery$ = strQuery$ + " & ( @Date(DATE_CREATED) >= [" + Format$(doc.FieldName1(0),“Short Date”) + “] )”

strQuery$ = strQuery$ + " & ( @Time(DATE_CREATED) >= [" + Format$(doc.FieldName2(0),“Short Time”) + “] )”

Subject: RE: Searching using Time Values…

Point well-taken . . . guess I’m just a stereotypical American who assumes that the rest of the world runs on my time in my format. :o)dgg