QUERY HELP: Time element / Ordering Issue

floridaboy2004

New Member
Joined
Nov 17, 2004
Messages
44
Hello,

I have a table titled "CUSTOMERS." In that table there are 2 (short-time) time fields:

"DESSERT TIME"
"MEAL TIME"

I want to establish a query that ONLY collects those customers that ordered 'DESSERT' PRIOR to ordering their 'MEAL' by utilizing the 2 times.

FYI, both times are in the format of '03:45' (short time) time with NO A.M. or P.M. designation.

Thanks a million to those who help and have taken the time to read! :)
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
As in your other post I think you need to create an expression using DateDiff.

eg

MinsBetweenOrders:DateDiff("n", MealTime, DessertTime)

Then apply appropriate criteria.
 
Upvote 0
Hello Norie,

I tried doing what you suggested and using '<4' (for 4 hours or less) as my criteria but it is giving me values such as '-3064425' when I use 2 times such as '21:29' and '22:15.'

How should I write my criteria to give me ALL values where the purchase time is less than 2 hours of the initial entry time?

Thanks for your patience and generosity! :)
 
Upvote 0
The expression I posted counts minutes not hours.

I don't know why you are getting the result you mention - it worked for me.

You say the format is short time but what are the actual values?
 
Upvote 0
Maybe you could flag records where DessertTime is less than MealTime --
DessertFirst:IIF([DessertTime]<[MealTime],1,0)
Alternatively, IIF([DessertTime]<[MealTime],DateDiff("n",[MealTime],[DessertTime],0)

Denis
 
Upvote 0

Forum statistics

Threads
1,221,832
Messages
6,162,254
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top