Link to home
Start Free TrialLog in
Avatar of gpotenza
gpotenza

asked on

Convert Text to Time and Filter

I have a fieldin a table with a datatype of Text that I can use the Format([CollectTime],"hh:nn:ss") function to successfully text to time.  However I need to filter this data in the same query.

For example >=#15:15:00#

When I do I do not get results even though I can see some would qualify.

Help this is urgent!
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

gpotenza said:
>>datatype of Text

If the data type is text, then why are you using a data type of datetime for the filter comparison?

Compare text with text and datetime with datetime; when you try to mix them up you can get
unexpected results.
Avatar of gpotenza
gpotenza

ASKER

The data in the field represents a time that I need to filter by a timespan. (for example from 15:00 to 20:00)  How would I do that if the field datatype is text?
If the text is stored as hh:mm, then try:

[TimeField] Between "15:00" And "20:00"

or if that does not work:

[TimeField] >= "15:00" And [TimeField] <= "20:00"

Why are you storing this as text and not as datetime?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial