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!

Another Time Segment problem!

Status
Not open for further replies.

paulpeyton

Technical User
May 25, 2003
10
US
You guys have always been great in a pinch! Thanks in advance! I need to group data off of an event date-time field in 3 hour segments. ex. 9a-12p, 12p-3p, 3p-6p, and 6p-9p. I don't know how to write the formula. Any help is greatly appreciated!
 
Are these the only timeframes, or do you want them all?

I'll just use a brute force approach:

switch(hour({Bob.Order Date}) < 4, 1,
hour({Bob.Order Date}) < 7, 2,
hour({Bob.Order Date}) < 10, 3,
hour({Bob.Order Date}) < 13, 4,
hour({Bob.Order Date}) < 16, 5,
hour({Bob.Order Date}) < 19, 6,
hour({Bob.Order Date}) < 22, 7,
hour({Bob.Order Date}) < 25, 8
)

Replace {bob.order date} with your field.

Sorry, I couldn't test it right now, but it looks right.

-k

 
k-
yes, these are the only timeframes. I tried grouping your formula, and the results showed:
3 xxxx
4 xxxx
5 xxxx

I need:
9a-12p xxxx xxxxx
12p-3p xxxx xxxxx where &quot;x&quot; is only data from the specific time frame. Your formula had cross over. I have a thirty minute formula that works, but not one where I can group data from specific three hour blocks of time. Hope this clarifies. Thanks again!

 
Try this for the group formula:

//@groupme
switch(hour({Bob.Order Date}) <= 12, 1,
hour({Bob.Order Date}) <= 15, 2,
hour({Bob.Order Date}) <= 18, 3,
hour({Bob.Order Date}) <= 21, 4
)

Now for the display on the group, use another formula:


If @groupme = 1 then &quot;9AM - 12PM&quot;
else
if @groupme = 2 then &quot;12PM - 3PM&quot;
etc...

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top