Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time formula

Status
Not open for further replies.

rhoneyfi

MIS
Apr 8, 2002
200
US
I have a date/time field. I need a formula that does the following:

Ignores all records that come in after a specific time and ingores all that come in before a specific time.

Ex: ignore records that come in after 9 pm and before 6 am.

Thanks for any help.
 
Let me clarify a bit:

Since the field is a date/time, I know the formula would have to look something like this:

{Date_Time} < &quot;Anydate 22:00&quot; and {Date_Time} > &quot;Anydate 8:00&quot;

I am just not too sure of the syntax....
 
Put

(Time({Date_Time}) > Time(21,00,00) and Time({Date_Time}) <= Time(00,00,00))or(Time({Date_Time}) > Time(00,00,00) and Time({Date_Time}) < Time(06,00,00))

In the record selection formula.

Reebo
Scotland (Sunny with a Smile)
 
Do you mean:

{YourDateTimeField} in
(
DateTime(Date({YourDateTimeStart}),CTime(&quot;06:00:00&quot;) to
DateTime(Date({YourDateTimeEnd}),CTime(&quot;21:00:00&quot;)
)

If the two dates are more than a day apart, they will extract records before 6am and after 9pm until the last day in the range.

Or do you mean:

Date({YourDateTimeField}) in
(Date({YourDateTimeStart}) to Date({YourDateTimeEnd})) and
CTime({YourDateTimeField}) in
(CTime({YourDateTimeStart}) to CTime({YourDateTimeEnd}))

which will cut off at every 6am and every 9pm in the range.

Naith
 
This line:

(CTime({YourDateTimeStart}) to CTime({YourDateTimeEnd}))

should read:

(CTime(&quot;06:00:00&quot;) to CTime(&quot;21:00:00&quot;))

Naith
 
Naith,
Thanks for the formula. The second one was just what I was looking for. Excellent!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top